调用一个方法返回了null,但这个对象我没有调用,程序就报空指针错误
这个是调用的方法
public TmVhcVehicleMovement findByPreVehicleIdAndUlocNo(Long vehicleId, Long ulocId)
{
String hql = "from TmVhcVehicleMovement where tmVhcVehicleId=:tmVhcVehicleId and tmBasUlocId=:tmBasUlocId";
Map<String, Long> params = new HashMap();
params.put("tmVhcVehicleId", vehicleId);
params.put("tmBasUlocId", ulocId);
List<TmVhcVehicleMovement> list = find(hql, params);
if (StringUtil.isNotEmpty(list)) {
return (TmVhcVehicleMovement)list.get(0);
}
return null;
}
这个是我去做判断的时候
if(vhcVehicleMovementBO.findByPreVehicleIdAndUlocNo(vhcVehicle.getId(),trUloc.getId())==null){
System.out.println("11111-------------------------------");
}
这里没有进到输出11111,直接就报空指针了,这是为啥