|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsk.baka.tools.jpa.CriteriaList
public class CriteriaList
Builds a list of criteria: a pair of column name (or a JPA expression) and the desired value. All desired criteria must hold - the AND operator is used. This object is useful in particular when creating GUI filter submit forms.
Usage example:final CriteriaList crit = new CriteriaList().whereEqual("bean.id", 25L);
final Query query = em.createQuery("select JpaBean bean where " + crit.toJpaQueryCondition());
crit.feedParameters(query);
query.getResultList();
| Nested Class Summary | |
|---|---|
static class |
CriteriaList.Criteria
Holds a single criteria. |
| Field Summary | |
|---|---|
List<CriteriaList.Criteria> |
criteria
The criteria list. |
List<Object> |
queryParameters
The query parameters, valid after invocation of toJpaQueryCondition(). |
| Constructor Summary | |
|---|---|
CriteriaList()
|
|
| Method Summary | |
|---|---|
CriteriaList |
add(CriteriaList.Criteria criteria)
A convenience method to add a criteria |
CriteriaList |
equal(String jpaField,
Serializable value)
A convenience method to add a requirement of equality: jpaField = value |
void |
feedParameters(javax.persistence.Query query)
Feeds given query with current parameter list. |
CriteriaList |
getWithPrefix(String prefix)
Prefixes the JPA field expression with given prefix and returns a new Criteria list. |
CriteriaList |
like(String jpaField,
Serializable value)
A convenience method to add a requirement of likeness: jpaField LIKE value |
CriteriaList |
sameDay(String jpaField,
Date date)
Adds an "at-day" condition to this criteria list. |
String |
toJpaQueryCondition()
Converts a list of JPA criteria to a JPA query WHERE clause. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final List<CriteriaList.Criteria> criteria
public final List<Object> queryParameters
toJpaQueryCondition().
| Constructor Detail |
|---|
public CriteriaList()
| Method Detail |
|---|
public CriteriaList equal(String jpaField,
Serializable value)
jpaField - the JPA field name or an expression.value - the desired value.
public CriteriaList like(String jpaField,
Serializable value)
jpaField - the JPA field name or an expression.value - the desired value.
public CriteriaList add(CriteriaList.Criteria criteria)
criteria - the criteria
public CriteriaList sameDay(String jpaField,
Date date)
jpaField - the date JPA field or expressiondate - filters out records from day other than this day. The time component of this date is ignored.
public String toJpaQueryCondition()
public void feedParameters(javax.persistence.Query query)
current parameter list.
query - the JPA query.public CriteriaList getWithPrefix(String prefix)
prefix - the prefix to use
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||