Package org.hibernate.criterion
Class Example
java.lang.Object
org.hibernate.criterion.Example
- All Implemented Interfaces:
Serializable,Criterion
Support for query by example.
List results = session.createCriteria(Parent.class)
.add( Example.create(parent).ignoreCase() )
.createCriteria("child")
.add( Example.create( parent.getChild() ) )
.list();
"Examples" may be mixed and matched with "Expressions" in the same Criteria.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA strategy for choosing property values for inclusion in the query criteria -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedExample(Object entity, Example.PropertySelector selector) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddComponentTypedValues(String path, Object component, CompositeType type, List list, Criteria criteria, CriteriaQuery criteriaQuery) protected voidaddPropertyTypedValue(Object value, Type type, List list) protected voidappendComponentCondition(String path, Object component, CompositeType type, Criteria criteria, CriteriaQuery criteriaQuery, StringBuffer buf) protected voidappendPropertyCondition(String propertyName, Object propertyValue, Criteria criteria, CriteriaQuery cq, StringBuffer buf) static ExampleCreate a new instance, which includes all non-null properties by defaultUse the "like" operator for all string-valued propertiesenableLike(MatchMode matchMode) Use the "like" operator for all string-valued propertiesDon't exclude null or zero-valued propertiesexcludeProperty(String name) Exclude a particular named propertyExclude zero-valued propertiesgetTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) Return typed values for all parameters in the rendered SQL fragmentIgnore case for all string-valued propertiessetEscapeCharacter(Character escapeCharacter) Set escape character for "like" clausesetPropertySelector(Example.PropertySelector selector) Set the property selectortoSqlString(Criteria criteria, CriteriaQuery criteriaQuery) Render the SQL fragmenttoString()
-
Constructor Details
-
Example
-
-
Method Details
-
setEscapeCharacter
Set escape character for "like" clause -
setPropertySelector
Set the property selector -
excludeZeroes
Exclude zero-valued properties -
excludeNone
Don't exclude null or zero-valued properties -
enableLike
Use the "like" operator for all string-valued properties -
enableLike
Use the "like" operator for all string-valued properties -
ignoreCase
Ignore case for all string-valued properties -
excludeProperty
Exclude a particular named property -
create
Create a new instance, which includes all non-null properties by default- Parameters:
entity-- Returns:
- a new instance of Example
-
toString
-
toSqlString
Description copied from interface:CriterionRender the SQL fragment- Specified by:
toSqlStringin interfaceCriterion- Parameters:
criteria- The local criteriacriteriaQuery- The overal criteria query- Returns:
- The generated SQL fragment
- Throws:
HibernateException- Problem during rendering.
-
getTypedValues
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException Description copied from interface:CriterionReturn typed values for all parameters in the rendered SQL fragment- Specified by:
getTypedValuesin interfaceCriterion- Parameters:
criteria- The local criteriacriteriaQuery- The overal criteria query- Returns:
- The types values (for binding)
- Throws:
HibernateException- Problem determining types.
-
addPropertyTypedValue
-
addComponentTypedValues
protected void addComponentTypedValues(String path, Object component, CompositeType type, List list, Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException - Throws:
HibernateException
-
appendPropertyCondition
protected void appendPropertyCondition(String propertyName, Object propertyValue, Criteria criteria, CriteriaQuery cq, StringBuffer buf) throws HibernateException - Throws:
HibernateException
-
appendComponentCondition
protected void appendComponentCondition(String path, Object component, CompositeType type, Criteria criteria, CriteriaQuery criteriaQuery, StringBuffer buf) throws HibernateException - Throws:
HibernateException
-