List of usage examples for org.hibernate Criteria createCriteria
@Deprecated public Criteria createCriteria(String associationPath, String alias, int joinType, Criterion withClause) throws HibernateException;
From source file:com.rta.vsd.data.service.impl.ViolationDataServiceImpl.java
/** * /* w w w. ja v a2 s . c o m*/ * Gets a list of violations with their associated defects(VsdChannelDefect) by their statuses * * @author Eldon Barrows * @param dsContext * @param retrieveArabicData * @param statuses * @param testStatus * @return List<VsdViolation> * @throws VSDDataAccessException */ public List<VsdViolation> getViolationsWithDefectsByStatuses(DataServiceContext dsContext, boolean retrieveArabicData, List<Long> violationStatusIds, String testStatus) throws VSDDataAccessException { logger.info("getViolationsWithDefectsByStatuses -- START"); List<VsdViolation> violations = null; try { Session session = (Session) dsContext.getInternalContext(); Criteria criteria = session.createCriteria(VsdViolation.class, "violations") .add(Restrictions.eq("violations.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("violations.vsdInspections", "i", Criteria.LEFT_JOIN, Restrictions.eq("i.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("i.vsdPlateConditionByFrontPlateConditionId", "fpc", Criteria.LEFT_JOIN, Restrictions.eq("fpc.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("i.vsdPlateConditionByRearPlateConditionId", "rpc", Criteria.LEFT_JOIN, Restrictions.eq("rpc.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("i.vsdVehicleInfo", "vi", Criteria.LEFT_JOIN, Restrictions.eq("vi.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("vi.vsdDriverInfos", "di", Criteria.LEFT_JOIN, Restrictions.eq("di.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("vi.vsdOwnerInfos", "oi", Criteria.LEFT_JOIN, Restrictions.eq("oi.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("violations.vsdSeverityLevel", "s", Criteria.LEFT_JOIN, Restrictions.eq("s.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("violations.vsdChannelDefects", "cd", Criteria.LEFT_JOIN, Restrictions.eq("cd.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("cd.vsdChannelDefectTests", "cdt", Criteria.LEFT_JOIN, Restrictions.eq("cdt.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("cdt.vsdChannelTest", "ct", Criteria.LEFT_JOIN, Restrictions.eq("ct.isDeleted", IDataService.BOOL_FALSE)); if (testStatus != null) { criteria.add(Restrictions.eq("ct.testStatus", testStatus)); } criteria.createCriteria("violations.vsdViolationStatus", "vs", Criteria.LEFT_JOIN, Restrictions.eq("vs.isDeleted", IDataService.BOOL_FALSE)) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) .add(Restrictions.in("vs.violationStatusId", violationStatusIds)); violations = criteria.list(); logger.info("getViolationsWithDefectsByStatuses -- END"); return violations; } catch (Exception ex) { logger.error("An error occured in getViolationsWithDefectsByStatuses()"); logger.error(ex); throw new VSDDataAccessException(ex.getMessage(), ex); } }
From source file:com.rta.vsd.data.service.impl.ViolationDataServiceImpl.java
/** * //from w w w. j a va 2 s . c o m * Gets a list of violations with their associated defects(VsdChannelDefect) by their statuses * * @author Eldon Barrows * @param dsContext * @param retrieveArabicData * @param statuses * @param testStatus * @param isViolationDefect * @return List<VsdViolation> * @throws VSDDataAccessException */ public List<VsdViolation> getViolationsWithDefectsByStatuses(DataServiceContext dsContext, boolean retrieveArabicData, List<Long> violationStatusIds, String testStatus, Character isViolationDefect) throws VSDDataAccessException { logger.info("getViolationsWithDefectsByStatuses -- START"); List<VsdViolation> violations = null; try { Session session = (Session) dsContext.getInternalContext(); Criteria criteria = session.createCriteria(VsdViolation.class, "violations") .add(Restrictions.eq("violations.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("violations.vsdInspections", "i", Criteria.LEFT_JOIN, Restrictions.eq("i.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("i.vsdPlateConditionByFrontPlateConditionId", "fpc", Criteria.LEFT_JOIN, Restrictions.eq("fpc.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("i.vsdPlateConditionByRearPlateConditionId", "rpc", Criteria.LEFT_JOIN, Restrictions.eq("rpc.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("i.vsdVehicleInfo", "vi", Criteria.LEFT_JOIN, Restrictions.eq("vi.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("vi.vsdDriverInfos", "di", Criteria.LEFT_JOIN, Restrictions.eq("di.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("vi.vsdOwnerInfos", "oi", Criteria.LEFT_JOIN, Restrictions.eq("oi.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("violations.vsdSeverityLevel", "s", Criteria.LEFT_JOIN, Restrictions.eq("s.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("violations.vsdChannelDefects", "cd", Criteria.LEFT_JOIN, Restrictions.eq("cd.isDeleted", IDataService.BOOL_FALSE)) .add(Restrictions.eq("cd.isViolationDefect", isViolationDefect)) .createCriteria("cd.vsdDefect", "def", Criteria.LEFT_JOIN, Restrictions.eq("def.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("cd.vsdChannelDefectTests", "cdt", Criteria.LEFT_JOIN, Restrictions.eq("cdt.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("cdt.vsdChannelTest", "ct", Criteria.LEFT_JOIN, Restrictions.eq("ct.isDeleted", IDataService.BOOL_FALSE)); if (testStatus != null) { criteria.add(Restrictions.eq("ct.testStatus", testStatus)); } criteria.createCriteria("violations.vsdViolationStatus", "vs", Criteria.LEFT_JOIN, Restrictions.eq("vs.isDeleted", IDataService.BOOL_FALSE)) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) .add(Restrictions.in("vs.violationStatusId", violationStatusIds)); violations = criteria.list(); logger.info("getViolationsWithDefectsByStatuses -- END"); return violations; } catch (Exception ex) { logger.error("An error occured in getViolationsWithDefectsByStatuses()"); logger.error(ex); throw new VSDDataAccessException(ex.getMessage(), ex); } }
From source file:com.rta.vsd.data.service.impl.ViolationDataServiceImpl.java
/** * //from w ww. j a va 2 s . co m * Gets a list of violations with their associated defects(VsdChannelDefect) by their statuses * * @author Eldon Barrows * @param dsContext * @param retrieveArabicData * @param statuses * @param testStatus * @param reportedDate * @return List<VsdViolation> * @throws VSDDataAccessException */ public List<VsdViolation> getViolationsWithDefectsByStatuses(DataServiceContext dsContext, boolean retrieveArabicData, List<Long> violationStatusIds, String testStatus, Date reportedDate) throws VSDDataAccessException { logger.info("getViolationsWithDefectsByStatuses -- START"); List<VsdViolation> violations = null; try { Session session = (Session) dsContext.getInternalContext(); Criteria criteria = session.createCriteria(VsdViolation.class, "violations") .add(Restrictions.eq("violations.isDeleted", IDataService.BOOL_FALSE)) .add(Restrictions.eq("violations.reportedDate", reportedDate)) .createCriteria("violations.vsdInspections", "i", Criteria.LEFT_JOIN, Restrictions.eq("i.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("i.vsdPlateConditionByFrontPlateConditionId", "fpc", Criteria.LEFT_JOIN, Restrictions.eq("fpc.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("i.vsdPlateConditionByRearPlateConditionId", "rpc", Criteria.LEFT_JOIN, Restrictions.eq("rpc.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("i.vsdVehicleInfo", "vi", Criteria.LEFT_JOIN, Restrictions.eq("vi.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("vi.vsdDriverInfos", "di", Criteria.LEFT_JOIN, Restrictions.eq("di.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("vi.vsdOwnerInfos", "oi", Criteria.LEFT_JOIN, Restrictions.eq("oi.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("violations.vsdSeverityLevel", "s", Criteria.LEFT_JOIN, Restrictions.eq("s.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("violations.vsdChannelDefects", "cd", Criteria.LEFT_JOIN, Restrictions.eq("cd.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("cd.vsdChannelDefectTests", "cdt", Criteria.LEFT_JOIN, Restrictions.eq("cdt.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("cdt.vsdChannelTest", "ct", Criteria.LEFT_JOIN, Restrictions.eq("ct.isDeleted", IDataService.BOOL_FALSE)); if (testStatus != null) { criteria.add(Restrictions.eq("ct.testStatus", testStatus)); } criteria.createCriteria("violations.vsdViolationStatus", "vs", Criteria.LEFT_JOIN, Restrictions.eq("vs.isDeleted", IDataService.BOOL_FALSE)) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) .add(Restrictions.in("vs.violationStatusId", violationStatusIds)); violations = criteria.list(); logger.info("getViolationsWithDefectsByStatuses -- END"); return violations; } catch (Exception ex) { logger.error("An error occured in getViolationsWithDefectsByStatuses()"); logger.error(ex); throw new VSDDataAccessException(ex.getMessage(), ex); } }
From source file:com.rta.vsd.data.service.impl.ViolationDataServiceImpl.java
/** * //from ww w . ja v a2s. co m * Gets a list of violations with their associated defects(VsdChannelDefect) by their statuses * * @author Eldon Barrows * @param dsContext * @param retrieveArabicData * @param statuses * @param testStatus * @param reportedDate * @param isViolationDefect * @return List<VsdViolation> * @throws VSDDataAccessException */ public List<VsdViolation> getViolationsWithDefectsByStatuses(DataServiceContext dsContext, boolean retrieveArabicData, List<Long> violationStatusIds, String testStatus, Date reportedDate, Character isViolationDefect) throws VSDDataAccessException { logger.info("getViolationsWithDefectsByStatuses -- START"); List<VsdViolation> violations = null; try { Session session = (Session) dsContext.getInternalContext(); Criteria criteria = session.createCriteria(VsdViolation.class, "violations") .add(Restrictions.eq("violations.isDeleted", IDataService.BOOL_FALSE)) .add(Restrictions.eq("violations.reportedDate", reportedDate)) .createCriteria("violations.vsdInspections", "i", Criteria.LEFT_JOIN, Restrictions.eq("i.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("i.vsdPlateConditionByFrontPlateConditionId", "fpc", Criteria.LEFT_JOIN, Restrictions.eq("fpc.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("i.vsdPlateConditionByRearPlateConditionId", "rpc", Criteria.LEFT_JOIN, Restrictions.eq("rpc.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("i.vsdVehicleInfo", "vi", Criteria.LEFT_JOIN, Restrictions.eq("vi.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("vi.vsdDriverInfos", "di", Criteria.LEFT_JOIN, Restrictions.eq("di.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("vi.vsdOwnerInfos", "oi", Criteria.LEFT_JOIN, Restrictions.eq("oi.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("violations.vsdSeverityLevel", "s", Criteria.LEFT_JOIN, Restrictions.eq("s.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("violations.vsdChannelDefects", "cd", Criteria.LEFT_JOIN, Restrictions.eq("cd.isDeleted", IDataService.BOOL_FALSE)) .add(Restrictions.eq("cd.isViolationDefect", isViolationDefect)) .createCriteria("cd.vsdDefect", "def", Criteria.LEFT_JOIN, Restrictions.eq("def.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("cd.vsdChannelDefectTests", "cdt", Criteria.LEFT_JOIN, Restrictions.eq("cdt.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("cdt.vsdChannelTest", "ct", Criteria.LEFT_JOIN, Restrictions.eq("ct.isDeleted", IDataService.BOOL_FALSE)); if (testStatus != null) { criteria.add(Restrictions.eq("ct.testStatus", testStatus)); } criteria.createCriteria("violations.vsdViolationStatus", "vs", Criteria.LEFT_JOIN, Restrictions.eq("vs.isDeleted", IDataService.BOOL_FALSE)) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) .add(Restrictions.in("vs.violationStatusId", violationStatusIds)); violations = criteria.list(); logger.info("getViolationsWithDefectsByStatuses -- END"); return violations; } catch (Exception ex) { logger.error("An error occured in getViolationsWithDefectsByStatuses()"); logger.error(ex); throw new VSDDataAccessException(ex.getMessage(), ex); } }
From source file:com.rta.vsd.data.service.impl.ViolationDataServiceImpl.java
/** * /*from w w w .j a v a 2 s .c om*/ * Gets a list of violations with their associated defects(VsdChannelDefect) by their statuses and due date * * @author Eldon Barrows * @param dsContext * @param retrieveArabicData * @param statuses * @param testStatus * @param dueDate * @return List<VsdViolation> * @throws VSDDataAccessException */ public List<VsdViolation> getViolationsWithDefectsByStatusesAndDueDate(DataServiceContext dsContext, boolean retrieveArabicData, List<Long> violationStatusIds, String testStatus, Date dueDate) throws VSDDataAccessException { logger.info("getViolationsWithDefectsByStatusesAndDueDate -- START"); List<VsdViolation> violations = null; try { Session session = (Session) dsContext.getInternalContext(); Criteria criteria = session.createCriteria(VsdViolation.class, "violations") .add(Restrictions.eq("violations.isDeleted", IDataService.BOOL_FALSE)) .add(Restrictions.eq("violations.dueDate", dueDate)) .createCriteria("violations.vsdInspections", "i", Criteria.LEFT_JOIN, Restrictions.eq("i.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("i.vsdPlateConditionByFrontPlateConditionId", "fpc", Criteria.LEFT_JOIN, Restrictions.eq("fpc.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("i.vsdPlateConditionByRearPlateConditionId", "rpc", Criteria.LEFT_JOIN, Restrictions.eq("rpc.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("i.vsdVehicleInfo", "vi", Criteria.LEFT_JOIN, Restrictions.eq("vi.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("vi.vsdDriverInfos", "di", Criteria.LEFT_JOIN, Restrictions.eq("di.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("vi.vsdOwnerInfos", "oi", Criteria.LEFT_JOIN, Restrictions.eq("oi.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("violations.vsdSeverityLevel", "s", Criteria.LEFT_JOIN, Restrictions.eq("s.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("violations.vsdChannelDefects", "cd", Criteria.LEFT_JOIN, Restrictions.eq("cd.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("cd.vsdChannelDefectTests", "cdt", Criteria.LEFT_JOIN, Restrictions.eq("cdt.isDeleted", IDataService.BOOL_FALSE)) .createCriteria("cdt.vsdChannelTest", "ct", Criteria.LEFT_JOIN, Restrictions.eq("ct.isDeleted", IDataService.BOOL_FALSE)); if (testStatus != null) { criteria.add(Restrictions.eq("ct.testStatus", testStatus)); } criteria.createCriteria("violations.vsdViolationStatus", "vs", Criteria.LEFT_JOIN, Restrictions.eq("vs.isDeleted", IDataService.BOOL_FALSE)) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) .add(Restrictions.in("vs.violationStatusId", violationStatusIds)); violations = criteria.list(); logger.info("getViolationsWithDefectsByStatusesAndDueDate -- END"); return violations; } catch (Exception ex) { logger.error("An error occured in getViolationsWithDefectsByStatusesAndDueDate()"); logger.error(ex); throw new VSDDataAccessException(ex.getMessage(), ex); } }