1 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 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 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 toString() { 39 return "not " + criterion.toString(); 40 } 41 42 } 43 | Popular Tags |