在Hibernate下面有一个查询Criteria接口
想请教一下
通常都是crit.add(Expression.eq("user", user));
都是 eq.()这个方法
有没有  不等于 != 或<>这样的方法

解决方案 »

  1.   

    crit.add(Expression.ne("user", user));not equals
      

  2.   

    static Criterion allEq(java.util.Map propertyNameValues) 
              Apply an "equals" constraint to each property in the key set of a Map 
    static LogicalExpression and(Criterion lhs, Criterion rhs) 
              Return the conjuction of two expressions 
    static Criterion between(java.lang.String propertyName, java.lang.Object lo, java.lang.Object hi) 
              Apply a "between" constraint to the named property 
    static Conjunction conjunction() 
              Group expressions together in a single conjunction (A and B and C...) 
    static Disjunction disjunction() 
              Group expressions together in a single disjunction (A or B or C...) 
    static SimpleExpression eq(java.lang.String propertyName, java.lang.Object value) 
              Apply an "equal" constraint to the named property 
    static PropertyExpression eqProperty(java.lang.String propertyName, java.lang.String otherPropertyName) 
              Apply an "equal" constraint to two properties 
    static SimpleExpression ge(java.lang.String propertyName, java.lang.Object value) 
              Apply a "greater than or equal" constraint to the named property 
    static PropertyExpression geProperty(java.lang.String propertyName, java.lang.String otherPropertyName) 
              Apply a "greater than or equal" constraint to two properties 
    static SimpleExpression gt(java.lang.String propertyName, java.lang.Object value) 
              Apply a "greater than" constraint to the named property 
    static PropertyExpression gtProperty(java.lang.String propertyName, java.lang.String otherPropertyName) 
              Apply a "greater than" constraint to two properties 
    static Criterion idEq(java.lang.Object value) 
              Apply an "equal" constraint to the identifier property 
    static Criterion ilike(java.lang.String propertyName, java.lang.Object value) 
              A case-insensitive "like", similar to Postgres ilike operator 
    static Criterion ilike(java.lang.String propertyName, java.lang.String value, MatchMode matchMode) 
              A case-insensitive "like", similar to Postgres ilike operator 
    static Criterion in(java.lang.String propertyName, java.util.Collection values) 
              Apply an "in" constraint to the named property 
    static Criterion in(java.lang.String propertyName, java.lang.Object[] values) 
              Apply an "in" constraint to the named property 
    static Criterion isEmpty(java.lang.String propertyName) 
              Constrain a collection valued property to be empty 
    static Criterion isNotEmpty(java.lang.String propertyName) 
              Constrain a collection valued property to be non-empty 
    static Criterion isNotNull(java.lang.String propertyName) 
              Apply an "is not null" constraint to the named property 
    static Criterion isNull(java.lang.String propertyName) 
              Apply an "is null" constraint to the named property 
    static SimpleExpression le(java.lang.String propertyName, java.lang.Object value) 
              Apply a "less than or equal" constraint to the named property 
    static PropertyExpression leProperty(java.lang.String propertyName, java.lang.String otherPropertyName) 
              Apply a "less than or equal" constraint to two properties 
    static SimpleExpression like(java.lang.String propertyName, java.lang.Object value) 
              Apply a "like" constraint to the named property 
    static SimpleExpression like(java.lang.String propertyName, java.lang.String value, MatchMode matchMode) 
              Apply a "like" constraint to the named property 
    static SimpleExpression lt(java.lang.String propertyName, java.lang.Object value) 
              Apply a "less than" constraint to the named property 
    static PropertyExpression ltProperty(java.lang.String propertyName, java.lang.String otherPropertyName) 
              Apply a "less than" constraint to two properties 
    static NaturalIdentifier naturalId() 
                
    static SimpleExpression ne(java.lang.String propertyName, java.lang.Object value) 
              Apply a "not equal" constraint to the named property 
    static PropertyExpression neProperty(java.lang.String propertyName, java.lang.String otherPropertyName) 
              Apply a "not equal" constraint to two properties 
    static Criterion not(Criterion expression) 
              Return the negation of an expression 
    static LogicalExpression or(Criterion lhs, Criterion rhs) 
              Return the disjuction of two expressions 
    static Criterion sizeEq(java.lang.String propertyName, int size) 
              Constrain a collection valued property by size 
    static Criterion sizeGe(java.lang.String propertyName, int size) 
              Constrain a collection valued property by size 
    static Criterion sizeGt(java.lang.String propertyName, int size) 
              Constrain a collection valued property by size 
    static Criterion sizeLe(java.lang.String propertyName, int size) 
              Constrain a collection valued property by size 
    static Criterion sizeLt(java.lang.String propertyName, int size) 
              Constrain a collection valued property by size 
    static Criterion sizeNe(java.lang.String propertyName, int size) 
              Constrain a collection valued property by size 
    static Criterion sqlRestriction(java.lang.String sql) 
              Apply a constraint expressed in SQL. 
    static Criterion sqlRestriction(java.lang.String sql, java.lang.Object[] values, Type[] types) 
              Apply a constraint expressed in SQL, with the given JDBC parameters. 
    static Criterion sqlRestriction(java.lang.String sql, java.lang.Object value, Type type) 
              Apply a constraint expressed in SQL, with the given JDBC parameter. 
    樓主自己去看,有沒有!
      

  3.   

    static SimpleExpression  ne(String propertyName, Object value)  String属性与指定Object“不相等的”