2017-01-03 7 views
1

私はコードの下にしようとしたログインIDが「5」HQLでNOT LIKEを使用する方法は?

で始まらないすべての行を照会する

public class Employee implements Serializable { 


@Id 
@Column(name = "EMPSEQ") 
@GeneratedValue(strategy = GenerationType.AUTO) 
private Long empSeq; 
@Column(name = "EMPID") 
private String empId; 
@Column(name = "WINDOWSLOGINID") 
private String logInId; 

// assume respective getter and setter methods 
} 

以下のように、私は実体を持っている:

query = session.createQuery("select * from Employee e where e.logInId not like 5%"); 

上記のコードのdidn仕事はありません。あなたのクエリでHQL

+1

パターン(5%)を一重引用符で囲んではいけませんか? '5%'のように? – kosa

答えて

2

NOT LIKEを使用するための正しい方法は何であるエラーがあります:なっ

query = session.createQuery("select * from Employee e where e.logInId not like 5%"); 

query = session.createQuery("select * from Employee e where e.logInId not like '5%'"); 

e.logInIdは文字列ですので、あなたの条件5%を引用しなければなりません。

関連する問題