List of usage examples for org.hibernate Hibernate isInitialized
@SuppressWarnings("SimplifiableIfStatement") public static boolean isInitialized(Object proxy)
From source file:com.yunguchang.model.EntityConvert.java
public static TSysUserEntity toEntity(User obj) { if (obj == null) { return null; }//from ww w . j a v a 2 s .c om if (!Hibernate.isInitialized(obj)) { Hibernate.initialize(obj); } TSysUserEntity entity = new TSysUserEntity(); entity.setUserid(obj.getEid() == null ? obj.getUserId() : obj.getEid()); entity.setUserno(obj.getEid() == null ? obj.getUserId() : obj.getEid()); entity.setMobile(obj.getMobile()); entity.setUsername(obj.getUserName()); TSysOrgEntity orgEntity = new TSysOrgEntity(); orgEntity.setOrgid(obj.getOrgId()); entity.setDepartment(orgEntity); return entity; }
From source file:com.yunguchang.model.EntityConvert.java
public static TBusMainUserInfoEntity toMainUserEntity(User obj) { if (obj == null) { return null; }/* w w w . jav a2s. co m*/ if (!Hibernate.isInitialized(obj)) { Hibernate.initialize(obj); } TBusMainUserInfoEntity entity = new TBusMainUserInfoEntity(); entity.setUuid(obj.getEid() == null ? obj.getUserId() : obj.getEid()); entity.setMobile(obj.getMobile()); entity.setName(obj.getUserName()); TSysOrgEntity orgEntity = new TSysOrgEntity(); orgEntity.setOrgid(obj.getOrgId()); entity.setSysOrg(orgEntity); return entity; }
From source file:com.yunguchang.model.EntityConvert.java
public static ScheduleCar fromEntity(TBusScheduleCarEntity entity) { if (entity == null) { return null; }//w w w . j a v a2s . c om if (!Hibernate.isInitialized(entity)) { Hibernate.initialize(entity); } ScheduleCar scheduleCar = new ScheduleCar(); scheduleCar.setCar(fromEntity(entity.getCar())); scheduleCar.setDriver(fromEntity(entity.getDriver())); scheduleCar.setId(entity.getUuid()); scheduleCar.setStatus(ScheduleStatus.valueOf(entity.getStatus())); scheduleCar.setSchedule(fromEntityWithoutScheduleCars(entity.getSchedule())); if (Hibernate.isInitialized(entity.getRecord()) && entity.getRecord() != null) { Double startMile = entity.getRecord().getStartmile(); Double endMile = entity.getRecord().getEndmile(); if (startMile != null) { scheduleCar.setStartMiles(startMile); } else { startMile = 0d; } if (endMile != null) { scheduleCar.setKm(endMile - startMile); scheduleCar.setEndMiles(endMile); } } return scheduleCar; }
From source file:com.yunguchang.model.EntityConvert.java
/** * ?Apply//from w ww.jav a 2 s.com * * @param entity * @return */ public static Schedule fromEntityWithoutApply(TBusScheduleRelaEntity entity) { if (entity == null) { return null; } if (!Hibernate.isInitialized(entity)) { Hibernate.initialize(entity); } Schedule schedule = new Schedule(); schedule.setStart(entity.getStarttime()); schedule.setEnd(entity.getEndtime()); schedule.setStartPoint(entity.getStartpoint()); schedule.setWayPoint(entity.getWays()); schedule.setId(entity.getUuid()); schedule.setSender(fromEntity(entity.getSenduser())); schedule.setReceiver(fromEntity(entity.getReciveuser())); schedule.setStatus(entity.getStatus()); return schedule; }
From source file:com.yunguchang.model.EntityConvert.java
/** * ?ScheduleCar/*from ww w . j a va 2 s . c o m*/ * * @param entity * @return */ public static Schedule fromEntityWithoutScheduleCars(TBusScheduleRelaEntity entity) { if (entity == null) { return null; } if (!Hibernate.isInitialized(entity)) { Hibernate.initialize(entity); } Schedule schedule = new Schedule(); schedule.setStart(entity.getStarttime()); schedule.setEnd(entity.getEndtime()); schedule.setStartPoint(entity.getStartpoint()); schedule.setWayPoint(entity.getWays()); schedule.setId(entity.getUuid()); if (Hibernate.isInitialized(entity.getApplications())) { List<Application> applications = new ArrayList<>(); for (TBusApplyinfoEntity applyinfoEntity : entity.getApplications()) { Application application = fromEntity(applyinfoEntity); if (application != null) { applications.add(application); } schedule.setApplications(applications.toArray(new Application[] {})); } } schedule.setSender(fromEntity(entity.getSenduser())); schedule.setReceiver(fromEntity(entity.getReciveuser())); schedule.setStatus(entity.getStatus()); return schedule; }
From source file:com.yunguchang.model.EntityConvert.java
/** * ?ScheduleCar//from w w w.j a va2 s. c om * * @param entity * @return */ public static Schedule fromEntityWithScheduleCars(TBusScheduleRelaEntity entity) { if (entity == null) { return null; } if (!Hibernate.isInitialized(entity)) { Hibernate.initialize(entity); } Schedule schedule = fromEntityWithoutScheduleCars(entity); List<ScheduleCar> scheduleCars = new ArrayList<>(); if (entity.getScheduleCars() != null) { for (TBusScheduleCarEntity scheduleCarEntity : entity.getScheduleCars()) { if (scheduleCarEntity.getStatus().equals(ScheduleStatus.CANCELED.id()) || scheduleCarEntity.getStatus().equals(ScheduleStatus.NOT_IN_EFFECT.id())) { continue; } //we can't set schedule to the car again. //it causes an infinite recursion excpetion serialize as json ScheduleCar scheduleCar = fromEntity(scheduleCarEntity); scheduleCars.add(scheduleCar); } } schedule.setScheduleCars(scheduleCars.toArray(new ScheduleCar[] {})); if (entity.getApplications() != null && Hibernate.isInitialized(entity.getApplications())) { List<Application> applicationList = new ArrayList<>(); for (TBusApplyinfoEntity applyinfoEntity : entity.getApplications()) { //we can't set schedule to the car again. //it causes an infinite recursion excpetion serialize as json Application application = fromEntity(applyinfoEntity); applicationList.add(application); } schedule.setApplications(applicationList.toArray(new Application[] {})); } schedule.setId(entity.getUuid()); return schedule; }
From source file:com.yunguchang.model.EntityConvert.java
public static ReturningDepotEvent fromEntity(TBusReturningDepotEntity entity) { if (entity == null) { return null; }//w w w .ja va 2s . c o m if (!Hibernate.isInitialized(entity)) { Hibernate.initialize(entity); } ReturningDepotEvent returningDepotEvent = new ReturningDepotEvent(); returningDepotEvent.setCar(fromEntity(entity.getCar())); returningDepotEvent.getCar().setDriver(fromEntity(entity.getCar().getDriver())); returningDepotEvent.setEventTime(entity.getReturnTime()); return returningDepotEvent; }
From source file:com.yunguchang.model.EntityConvert.java
public static Driver fromEntity(TRsDriverinfoEntity entity) { if (entity == null) { return null; }//from w ww .ja v a 2 s. co m if (!Hibernate.isInitialized(entity)) { Hibernate.initialize(entity); } Driver driver = new Driver(); driver.setId(entity.getUuid()); driver.setMobile(entity.getMobile()); driver.setPhone(entity.getPhone()); String drivername = entity.getDrivername(); driver.setName(drivername); driver.setNamePinyin(getPinYin(drivername)); driver.setLicenseClass(entity.getLicenseClass()); // driver.setInternalLicenseClassCode(entity.getDrivecartype()); //? if (entity.getLeaveStatus() == null || OnWorkStateEnum.onWorkState.contains(entity.getLeaveStatus())) { if (entity.isOnWorking()) { driver.setDriverStatus(DriverStatus.WORK); } else { driver.setDriverStatus(DriverStatus.IDLE); } } else { driver.setDriverStatus(DriverStatus.LEAVE); } driver.setFleet(fromEntity(entity.getDepartment())); return driver; }
From source file:com.yunguchang.model.EntityConvert.java
public static LicenseVehicleMapping fromEntity(TAzJzRelaEntity entity) { if (entity == null) { return null; }/*from w w w .ja v a 2s. co m*/ if (!Hibernate.isInitialized(entity)) { Hibernate.initialize(entity); } LicenseVehicleMapping licenseVehicleMapping = new LicenseVehicleMapping(); licenseVehicleMapping.setLicenseClass(entity.getJzyq()); licenseVehicleMapping.setVehicleType(entity.getXszcx()); return licenseVehicleMapping; }
From source file:com.yunguchang.model.EntityConvert.java
public static Depot fromEntity(TEmbeddedDepot embeddedDepot) { if (embeddedDepot == null) { return null; }/*from w w w .j av a2 s. c om*/ if (!Hibernate.isInitialized(embeddedDepot)) { Hibernate.initialize(embeddedDepot); } Depot depot = new Depot(); depot.setLng(embeddedDepot.getLongitude()); depot.setLat(embeddedDepot.getLatitude()); depot.setName(embeddedDepot.getName()); return depot; }