站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Hibernate 2.1.8 正式版 API 英文文档

Example (Hibernate API Documentation) - Hibernate 2.1.8 正式版 API 英文文档


net.sf.hibernate.expression
Class Example

java.lang.Object
  extended bynet.sf.hibernate.expression.AbstractCriterion
      extended bynet.sf.hibernate.expression.Example
All Implemented Interfaces:
Criterion

public class Example
extends AbstractCriterion

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.

Author:
Gavin King
See Also:
Criteria

Nested Class Summary
static interface Example.PropertySelector
          A strategy for choosing property values for inclusion in the query criteria
 
Constructor Summary
protected Example(Object entity, Example.PropertySelector selector)
           
 
Method Summary
protected  void addComponentTypedValues(String path, Object component, AbstractComponentType type, List list)
           
protected  void addPropertyTypedValue(Object value, Type type, List list)
           
protected  void appendComponentCondition(String path, Object component, AbstractComponentType type, Class persistentClass, String alias, Map aliasClasses, SessionFactoryImplementor sessionFactory, StringBuffer buf)
           
protected  void appendPropertyCondition(String propertyName, Object propertyValue, Class persistentClass, String alias, Map aliasClasses, SessionFactoryImplementor sessionFactory, StringBuffer buf)
           
static Example create(Object entity)
          Create a new instance, which includes all non-null properties by default
 Example enableLike()
          Use the "like" operator for all string-valued properties
 Example enableLike(MatchMode matchMode)
          Use the "like" operator for all string-valued properties
 Example excludeNone()
          Don't exclude null or zero-valued properties
 Example excludeProperty(String name)
          Exclude a particular named property
 Example excludeZeroes()
          Exclude zero-valued properties
 TypedValue[] getTypedValues(SessionFactoryImplementor sessionFactory, Class persistentClass, Map aliasClasses)
          Return typed values for all parameters in the rendered SQL fragment
 Example ignoreCase()
          Ignore case for all string-valued properties
 Example setPropertySelector(Example.PropertySelector selector)
          Set the property selector
 String toSqlString(SessionFactoryImplementor sessionFactory, Class persistentClass, String alias, Map aliasClasses)
          Render the SQL fragment
 String toString()
          For cosmetic purposes only!
 
Methods inherited from class net.sf.hibernate.expression.AbstractCriterion
getColumns, getType, getTypedValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Example

protected Example(Object entity,
                  Example.PropertySelector selector)
Method Detail

setPropertySelector

public Example setPropertySelector(Example.PropertySelector selector)
Set the property selector


excludeZeroes

public Example excludeZeroes()
Exclude zero-valued properties


excludeNone

public Example excludeNone()
Don't exclude null or zero-valued properties


enableLike

public Example enableLike(MatchMode matchMode)
Use the "like" operator for all string-valued properties


enableLike

public Example enableLike()
Use the "like" operator for all string-valued properties


ignoreCase

public Example ignoreCase()
Ignore case for all string-valued properties


excludeProperty

public Example excludeProperty(String name)
Exclude a particular named property


create

public static Example create(Object entity)
Create a new instance, which includes all non-null properties by default

Parameters:
entity -
Returns:
a new instance of Example

toString

public String toString()
Description copied from class: AbstractCriterion
For cosmetic purposes only!

Specified by:
toString in class AbstractCriterion
See Also:
Object.toString()

toSqlString

public String toSqlString(SessionFactoryImplementor sessionFactory,
                          Class persistentClass,
                          String alias,
                          Map aliasClasses)
                   throws HibernateException
Description copied from interface: Criterion
Render the SQL fragment

Parameters:
sessionFactory -
persistentClass -
alias -
Returns:
String
Throws:
HibernateException

getTypedValues

public TypedValue[] getTypedValues(SessionFactoryImplementor sessionFactory,
                                   Class persistentClass,
                                   Map aliasClasses)
                            throws HibernateException
Description copied from interface: Criterion
Return typed values for all parameters in the rendered SQL fragment

Parameters:
sessionFactory -
persistentClass -
Returns:
TypedValue[]
Throws:
HibernateException

addPropertyTypedValue

protected void addPropertyTypedValue(Object value,
                                     Type type,
                                     List list)

addComponentTypedValues

protected void addComponentTypedValues(String path,
                                       Object component,
                                       AbstractComponentType type,
                                       List list)
                                throws HibernateException
Throws:
HibernateException

appendPropertyCondition

protected void appendPropertyCondition(String propertyName,
                                       Object propertyValue,
                                       Class persistentClass,
                                       String alias,
                                       Map aliasClasses,
                                       SessionFactoryImplementor sessionFactory,
                                       StringBuffer buf)
                                throws HibernateException
Throws:
HibernateException

appendComponentCondition

protected void appendComponentCondition(String path,
                                        Object component,
                                        AbstractComponentType type,
                                        Class persistentClass,
                                        String alias,
                                        Map aliasClasses,
                                        SessionFactoryImplementor sessionFactory,
                                        StringBuffer buf)
                                 throws HibernateException
Throws:
HibernateException