HIbernate查询使用AND,OR,NOT条件

时间:2013-01-28 10:47:27

标签: mysql oracle hibernate hql

我的sql表和Hibernae Pojo类与Message:相同 - >专栏toList,fromList,deleteList

我正在准备Query:只在toList和fromList中没有在deleteList;

Query:select mb from Message mb where mb.toList LIKE :searchKey OR mb.fromList LIKE :searchKey

以及如何在DeleteList条件下写NOT。

1 个答案:

答案 0 :(得分:0)

请参阅hibernate expression以了解HQL中可用的所有操作数。

根据您的情况:

Query: only in toList and fromList not in deleteList;

这应该可以正常运作:

select mb from Message mb 
where mb.toList LIKE :searchKey 
AND mb.fromList LIKE :searchKey
AND NOT mb.deleteList LIKE :searchKey