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.
org.hibernate.Criteria
| Modifier and Type | Class and Description |
|---|---|
| public static class | Example.AllPropertySelector
Property selector that includes all properties |
| public static class | Example.NotNullOrZeroPropertySelector
Property selector that includes only properties that are not |
| public static class | Example.NotNullPropertySelector
Property selector that includes only properties that are not |
| public static interface | Example.PropertySelector
A strategy for choosing property values for inclusion in the query criteria. |
| Modifier and Type | Field and Description |
|---|---|
| private Character | |
| private final Object | |
| private final Set | |
| private boolean | |
| private boolean | |
| private MatchMode | |
| private Example. |
| Access | Constructor and Description |
|---|---|
| protected | Example(Object
The example bean exampleEntity, Example.The property selector to use selectorAllow subclasses to instantiate as needed. |
| Modifier and Type | Method and Description |
|---|---|
| protected void | addComponentTypedValues(String path, Object component, CompositeType type, List<TypedValue> list, Criteria criteria, CriteriaQuery criteriaQuery)
|
| protected void | |
| protected void | appendComponentCondition(String path, Object component, CompositeType type, Criteria criteria, CriteriaQuery criteriaQuery, StringBuilder buf)
|
| protected void | appendPropertyCondition(String propertyName, Object propertyValue, Criteria criteria, CriteriaQuery cq, StringBuilder buf)
|
| public static Example | |
| public Example | Returns: this, for method chainingUse the "like" operator for all string-valued properties. |
| public Example | Returns: this, for method chainingThe match mode to use. matchMode)Use the "like" operator for all string-valued properties |
| public Example | |
| public Example | Returns: this, for method chainingThe name of the property to exclude name)Exclude a particular property by name. |
| public Example | |
| private EntityMode | |
| public TypedValue[] | getTypedValues(Criteria
The local criteria criteria, CriteriaQuery The overall criteria query criteriaQuery)Implements org. |
| public Example | |
| private boolean | |
| public Example | Returns: this, for method chainingThe escape character escapeCharacter)Set escape character for "like" clause if like matching was enabled |
| public Example | Returns: this, for method chainingThe selector to use selectorSet the property selector to use. |
| public String | toSqlString(Criteria
The local criteria criteria, CriteriaQuery The overall criteria query criteriaQuery)Implements org. |
| public String |
| escapeCharacter | back to summary |
|---|---|
| private Character escapeCharacter | |
| exampleEntity | back to summary |
|---|---|
| private final Object exampleEntity | |
| excludedProperties | back to summary |
|---|---|
| private final Set<String> excludedProperties | |
| isIgnoreCaseEnabled | back to summary |
|---|---|
| private boolean isIgnoreCaseEnabled | |
| isLikeEnabled | back to summary |
|---|---|
| private boolean isLikeEnabled | |
| matchMode | back to summary |
|---|---|
| private MatchMode matchMode | |
| selector | back to summary |
|---|---|
| private Example. | |
| Example | back to summary |
|---|---|
| protected Example(Object exampleEntity, Example. Allow subclasses to instantiate as needed.
| |
| addComponentTypedValues | back to summary |
|---|---|
| protected void addComponentTypedValues(String path, Object component, CompositeType type, List<TypedValue> list, Criteria criteria, CriteriaQuery criteriaQuery) | |
| addPropertyTypedValue | back to summary |
|---|---|
| protected void addPropertyTypedValue(Object value, Type type, List<TypedValue> list) | |
| appendComponentCondition | back to summary |
|---|---|
| protected void appendComponentCondition(String path, Object component, CompositeType type, Criteria criteria, CriteriaQuery criteriaQuery, StringBuilder buf) | |
| appendPropertyCondition | back to summary |
|---|---|
| protected void appendPropertyCondition(String propertyName, Object propertyValue, Criteria criteria, CriteriaQuery cq, StringBuilder buf) | |
| create | back to summary |
|---|---|
| public static Example create(Object exampleEntity) Create a new Example criterion instance, which includes all non-null properties by default | |
| enableLike | back to summary |
|---|---|
| public Example enableLike() Use the "like" operator for all string-valued properties. This form implicitly uses
| |
| enableLike | back to summary |
|---|---|
| public Example enableLike(MatchMode matchMode) Use the "like" operator for all string-valued properties | |
| excludeNone | back to summary |
|---|---|
| public Example excludeNone() Include all properties.
Equivalent to calling
| |
| excludeProperty | back to summary |
|---|---|
| public Example excludeProperty(String name) Exclude a particular property by name.
| |
| excludeZeroes | back to summary |
|---|---|
| public Example excludeZeroes() Exclude zero-valued properties.
Equivalent to calling
| |
| getEntityMode | back to summary |
|---|---|
| private EntityMode getEntityMode(Criteria criteria, CriteriaQuery criteriaQuery) | |
| getTypedValues | back to summary |
|---|---|
| public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) Implements org. Doc from org. Return typed values for all parameters in the rendered SQL fragment
| |
| ignoreCase | back to summary |
|---|---|
| public Example ignoreCase() Ignore case for all string-valued properties
| |
| isPropertyIncluded | back to summary |
|---|---|
private boolean isPropertyIncluded(Object value, String name, Type type)
| |
| setEscapeCharacter | back to summary |
|---|---|
| public Example setEscapeCharacter(Character escapeCharacter) Set escape character for "like" clause if like matching was enabled
| |
| setPropertySelector | back to summary |
|---|---|
| public Example setPropertySelector(Example. Set the property selector to use. The property selector operates separately from excluding a property.
| |
| toSqlString | back to summary |
|---|---|
| public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) Implements org. Doc from org. Render the SQL fragment
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| Modifier and Type | Field and Description |
|---|---|
| public static final Example. | INSTANCE
Singleton access |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | include(Object
The property value (from the example bean) object, String The name of the property propertyName, Type The type of the property type)Implements org. |
| private Object |
| INSTANCE | back to summary |
|---|---|
| public static final Example. Singleton access | |
| AllPropertySelector | back to summary |
|---|---|
| public AllPropertySelector() | |
| include | back to summary |
|---|---|
| public boolean include(Object object, String propertyName, Type type) Implements org. Doc from org. Determine whether the given property should be used in the criteria. | |
| readResolve | back to summary |
|---|---|
| private Object readResolve() | |
null and non-zero (if numeric)
| Modifier and Type | Field and Description |
|---|---|
| public static final Example. | INSTANCE
Singleton access |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | include(Object
The property value (from the example bean) object, String The name of the property propertyName, Type The type of the property type)Implements org. |
| private Object |
| INSTANCE | back to summary |
|---|---|
| public static final Example. Singleton access | |
| NotNullOrZeroPropertySelector | back to summary |
|---|---|
| public NotNullOrZeroPropertySelector() | |
| include | back to summary |
|---|---|
| public boolean include(Object object, String propertyName, Type type) Implements org. Doc from org. Determine whether the given property should be used in the criteria. | |
| readResolve | back to summary |
|---|---|
| private Object readResolve() | |
null
| Modifier and Type | Field and Description |
|---|---|
| public static final Example. | INSTANCE
Singleton access |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | include(Object
The property value (from the example bean) object, String The name of the property propertyName, Type The type of the property type)Implements org. |
| private Object |
| INSTANCE | back to summary |
|---|---|
| public static final Example. Singleton access | |
| NotNullPropertySelector | back to summary |
|---|---|
| public NotNullPropertySelector() | |
| include | back to summary |
|---|---|
| public boolean include(Object object, String propertyName, Type type) Implements org. Doc from org. Determine whether the given property should be used in the criteria. | |
| readResolve | back to summary |
|---|---|
| private Object readResolve() | |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true indicates the property should be included; false indicates it should not.The property value (from the example bean) propertyValue, String The name of the property propertyName, Type The type of the property type)Determine whether the given property should be used in the criteria. |
| include | back to summary |
|---|---|
| public boolean include(Object propertyValue, String propertyName, Type type) Determine whether the given property should be used in the criteria. | |