From: <one...@us...> - 2003-03-09 04:04:38
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv31647/hibernate Modified Files: Criteria.java Interceptor.java Lifecycle.java Query.java Session.java Log Message: expanded Criteria API allowed unmapped-class queries with new from syntax Index: Criteria.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/Criteria.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Criteria.java 8 Mar 2003 06:31:22 -0000 1.1 --- Criteria.java 9 Mar 2003 04:04:04 -0000 1.2 *************** *** 5,11 **** import net.sf.hibernate.expression.Expression; /** ! * <tt>Criteria</tt> is a simplified API for retrieving objects * by composing <tt>Expression</tt> objects. This is a very * convenient approach for functionality like "search" screens --- 5,12 ---- import net.sf.hibernate.expression.Expression; + import net.sf.hibernate.expression.Order; /** ! * <tt>Criteria</tt> is a simplified API for retrieving entities * by composing <tt>Expression</tt> objects. This is a very * convenient approach for functionality like "search" screens *************** *** 13,22 **** * upon the result set.<br> * <br> * In the current implementation, conditions may only be placed * upon properties of the class being retrieved (and its * components). Hibernate's query language is much more general ! * and should be used for non-simple cases. * <br> * <i>This is an experimental API</i> */ public interface Criteria { --- 14,36 ---- * upon the result set.<br> * <br> + * The <tt>Session</tt> is a factory for <tt>Criteria</tt>. + * <tt>Expression</tt> instances are usually obtained via + * the factory methods on <tt>Expression</tt>. eg. + * <pre> + * List cats = session.createCriteria(Cat.class) + * .add( Expression.like("name", "Iz%") ) + * .add( Expression.gt( "weight", new Float(minWeight) ) ) + * .addOrder( Order.asc("age") ) + * .list(); + * </pre> * In the current implementation, conditions may only be placed * upon properties of the class being retrieved (and its * components). Hibernate's query language is much more general ! * and should be used for non-simple cases.<br> * <br> * <i>This is an experimental API</i> + * + * @see Session#createCriteria(java.lang.Class) + * @see net.sf.hibernate.expression.Expression */ public interface Criteria { *************** *** 50,53 **** --- 64,75 ---- */ public Criteria add(Expression expression); + + /** + * An an <tt>Order</tt> to the result set + * + * @param order + * @return Criteria + */ + public Criteria addOrder(Order order); /** * Get the results Index: Interceptor.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/Interceptor.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Interceptor.java 28 Jan 2003 10:22:18 -0000 1.6 --- Interceptor.java 9 Mar 2003 04:04:04 -0000 1.7 *************** *** 20,24 **** * * @see SessionFactory#openSession(Interceptor) ! * @see net.sf.hibernate.cfg.Configuration#buildSessionFactory(Interceptor) */ public interface Interceptor { --- 20,24 ---- * * @see SessionFactory#openSession(Interceptor) ! * @see net.sf.hibernate.cfg.Configuration#setInterceptor(Interceptor) */ public interface Interceptor { Index: Lifecycle.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/Lifecycle.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Lifecycle.java 5 Jan 2003 02:11:19 -0000 1.3 --- Lifecycle.java 9 Mar 2003 04:04:05 -0000 1.4 *************** *** 9,13 **** * required to.<br> * <br> ! * <b>onSave:</b> called just before the object is saved or inserted<br> * <b>onUpdate:</b> called just before an object is updated, * ie. when <tt>Session.update()</tt> is called<br> --- 9,13 ---- * required to.<br> * <br> ! * <b>onSave:</b> called just before the object is saved<br> * <b>onUpdate:</b> called just before an object is updated, * ie. when <tt>Session.update()</tt> is called<br> *************** *** 34,38 **** * <br> * Note that <tt>onSave()</tt> is called after an identifier is assigned ! * to the object, except when native key generation is used. * @see CallbackException */ --- 34,38 ---- * <br> * Note that <tt>onSave()</tt> is called after an identifier is assigned ! * to the object, except when identity column key generation is used. * @see CallbackException */ Index: Query.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/Query.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Query.java 4 Mar 2003 10:53:46 -0000 1.8 --- Query.java 9 Mar 2003 04:04:05 -0000 1.9 *************** *** 180,183 **** --- 180,201 ---- /** + * Bind multiple values to a named query parameter. This is useful for binding + * a list of values to an expression such as <tt>foo.bar in (:value_list)</tt>. + * @param name the name of the parameter + * @param vals a collection of values to list + * @param type the Hibernate type of the values + */ + public Query setParameterList(String name, Object[] vals, Type type) throws HibernateException; + + /** + * Bind multiple values to a named query parameter, guessing the Hibernate type from the + * class of the first object in the array. This is useful for binding a list of values + * to an expression such as <tt>foo.bar in (:value_list)</tt>. + * @param name the name of the parameter + * @param vals a collection of values to list + */ + public Query setParameterList(String name, Object[] vals) throws HibernateException; + + /** * Bind the property values of the given bean to named parameters of the query, * matching property names with parameter names and mapping property types to Index: Session.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/Session.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Session.java 8 Mar 2003 06:31:22 -0000 1.10 --- Session.java 9 Mar 2003 04:04:05 -0000 1.11 *************** *** 466,469 **** --- 466,476 ---- public Transaction beginTransaction() throws HibernateException; + /** + * Create a new <tt>Criteria</tt> instance, for the given + * entity class + * + * @param persistentClass + * @return Criteria + */ public Criteria createCriteria(Class persistentClass); |