List of usage examples for org.hibernate.criterion CriteriaQuery getColumns
public String[] getColumns(String propertyPath, Criteria criteria) throws HibernateException;
From source file:com.court.controller.HomeFXMLController.java
private Criterion filterByMonthCriterion(final String propertyName) { return new Criterion() { final int month = new Date().getMonth() + 1; @Override/* ww w . j av a 2s.c o m*/ public String toSqlString(Criteria crtr, CriteriaQuery cq) throws HibernateException { String[] columns = cq.getColumns(propertyName, crtr); if (columns.length != 1) { throw new HibernateException("monthEq may only be used with single-column properties"); } return "month(" + columns[0] + ") = ?"; } @Override public TypedValue[] getTypedValues(Criteria crtr, CriteriaQuery cq) throws HibernateException { return new TypedValue[] { new TypedValue(IntegerType.INSTANCE, month, EntityMode.POJO) }; } @Override public String toString() { return "month(" + propertyName + ") = " + month; } }; }
From source file:common.util.db.MonthEqExpression.java
@Override public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { String[] columns = criteriaQuery.getColumns(propertyName, criteria); if (columns.length != 1) { throw new HibernateException("monthEq may only be used with single-column properties"); }//from w w w . j a v a 2s .com return "extract(month from " + columns[0] + ") = ?"; }
From source file:common.util.db.MonthGroupExpression.java
@Override public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { String[] columns = criteriaQuery.getColumns(propertyName, criteria); if (columns.length != 1) { throw new HibernateException("monthGroup may only be used with single-column properties"); }/*from ww w . j av a 2 s. co m*/ return "extract(month from " + columns[0] + ")"; }
From source file:common.util.db.YearEqExpression.java
@Override public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { String[] columns = criteriaQuery.getColumns(propertyName, criteria); if (columns.length != 1) { throw new HibernateException("yearEq may only be used with single-column properties"); }/*from w w w . j av a 2 s . c o m*/ return "extract(year from " + columns[0] + ") = ?"; }