01: //$Id: Expression.java 5685 2005-02-12 07:19:50Z steveebersole $
02: package org.hibernate.criterion;
03:
04: import org.hibernate.type.Type;
05: import org.hibernate.util.ArrayHelper;
06:
07: /**
08: * This class is semi-deprecated. Use <tt>Restrictions</tt>.
09: *
10: * @see Restrictions
11: * @author Gavin King
12: */
13: public final class Expression extends Restrictions {
14:
15: private Expression() {
16: //cannot be instantiated
17: }
18:
19: /**
20: * Apply a constraint expressed in SQL, with the given JDBC
21: * parameters. Any occurrences of <tt>{alias}</tt> will be
22: * replaced by the table alias.
23: *
24: * @param sql
25: * @param values
26: * @param types
27: * @return Criterion
28: */
29: public static Criterion sql(String sql, Object[] values,
30: Type[] types) {
31: return new SQLCriterion(sql, values, types);
32: }
33:
34: /**
35: * Apply a constraint expressed in SQL, with the given JDBC
36: * parameter. Any occurrences of <tt>{alias}</tt> will be replaced
37: * by the table alias.
38: *
39: * @param sql
40: * @param value
41: * @param type
42: * @return Criterion
43: */
44: public static Criterion sql(String sql, Object value, Type type) {
45: return new SQLCriterion(sql, new Object[] { value },
46: new Type[] { type });
47: }
48:
49: /**
50: * Apply a constraint expressed in SQL. Any occurrences of <tt>{alias}</tt>
51: * will be replaced by the table alias.
52: *
53: * @param sql
54: * @return Criterion
55: */
56: public static Criterion sql(String sql) {
57: return new SQLCriterion(sql, ArrayHelper.EMPTY_OBJECT_ARRAY,
58: ArrayHelper.EMPTY_TYPE_ARRAY);
59: }
60:
61: }
|