我有一个实体,如下所示
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
}
我想查询logInId不以“5”开头的所有行
我尝试了以下代码:
query = session.createQuery("select * from Employee e where e.logInId not like 5%");
上面的代码没有用。在NOT LIKE
HQL
的正确方法是什么
答案 0 :(得分:2)
在您的查询中出现错误:
void worker(int workerId)
{
Console.WriteLine("Worker {0} is starting.", workerId);
do {
string op;
while(iQ.TryDequeue(out op))
{
Console.WriteLine("Worker {0} is processing item {1}", workerId, op);
}
SpinWait.SpinUntil(() => Volatile.Read(ref doneEnqueueing) || (iQ.Count > 0));
}
while (!Volatile.Read(ref doneEnqueueing) || (iQ.Count > 0))
Console.WriteLine("Worker {0} is stopping.", workerId);
}
成为:
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%'");
是字符串,因此您必须引用5%的条件。