KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > criterion > SimpleSubqueryExpression


1 //$Id: SimpleSubqueryExpression.java,v 1.5 2005/02/18 03:47:27 oneovthafew Exp $
2
package org.hibernate.criterion;
3
4 import org.hibernate.Criteria;
5 import org.hibernate.EntityMode;
6 import org.hibernate.HibernateException;
7 import org.hibernate.engine.TypedValue;
8
9 /**
10  * A comparison between a constant value and the the result of a subquery
11  * @author Gavin King
12  */

13 public class SimpleSubqueryExpression extends SubqueryExpression {
14     
15     private Object JavaDoc value;
16     
17     protected SimpleSubqueryExpression(Object JavaDoc value, String JavaDoc op, String JavaDoc quantifier, DetachedCriteria dc) {
18         super(op, quantifier, dc);
19         this.value = value;
20     }
21     
22     
23     public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
24     throws HibernateException {
25         TypedValue[] superTv = super.getTypedValues(criteria, criteriaQuery);
26         TypedValue[] result = new TypedValue[superTv.length+1];
27         System.arraycopy(superTv, 0, result, 1, superTv.length);
28         result[0] = new TypedValue( getTypes()[0], value, EntityMode.POJO );
29         return result;
30     }
31     
32     protected String JavaDoc toLeftSqlString(Criteria criteria, CriteriaQuery criteriaQuery) {
33         return "?";
34     }
35 }
36
Popular Tags