KickJava   Java API By Example, From Geeks To Geeks.

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


1 //$Id: NotExpression.java,v 1.9 2005/02/12 07:19:13 steveebersole Exp $
2
package org.hibernate.criterion;
3
4
5 import org.hibernate.Criteria;
6 import org.hibernate.HibernateException;
7 import org.hibernate.dialect.MySQLDialect;
8 import org.hibernate.engine.TypedValue;
9
10 /**
11  * Negates another criterion
12  * @author Gavin King
13  */

14 public class NotExpression implements Criterion {
15
16     private Criterion criterion;
17
18     protected NotExpression(Criterion criterion) {
19         this.criterion = criterion;
20     }
21
22     public String JavaDoc toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
23     throws HibernateException {
24         if ( criteriaQuery.getFactory().getDialect() instanceof MySQLDialect ) {
25             return "not (" + criterion.toSqlString(criteria, criteriaQuery) + ')';
26         }
27         else {
28             return "not " + criterion.toSqlString(criteria, criteriaQuery);
29         }
30     }
31
32     public TypedValue[] getTypedValues(
33         Criteria criteria, CriteriaQuery criteriaQuery)
34     throws HibernateException {
35         return criterion.getTypedValues(criteria, criteriaQuery);
36     }
37
38     public String JavaDoc toString() {
39         return "not " + criterion.toString();
40     }
41
42 }
43
Popular Tags