请高手帮忙解释下WHERE子句中IS EMPTY的意思。
我理解是在一个表User中,数据如下。
+----+-----------+-----------+------------+---------------------+
| id | username | userage | usergender | userhobby |
+----+-----------+-----------+------------+---------------------+
| 10 | nana | 20 | 1 | |
| 11 | longbao | 20 | 1 | |
| 12 | hali | 20 | 1 | sing dancing |
+----+-----------+-----------+------------+---------------------+
JPQL:select u from User u where u.userhobby IS EMPTY;
应该出来的内容为前两条记录,但是不是是检索不到,而且console中打出来的hibernate语句为:
select
user0_.id as id3_,
user0_.userage as userage3_,
user0_.usergender as usergender3_,
user0_.userhobby as userhobby3_,
user0_.username as username3_
from
test123.user user0_
where
not (exists (select
user0_.id
from
test123.user user0_))
这该怎么理解呢?
同事“秀才”点了一下,应该是对于一对多的关系才会有这中用法。
用户表中的用户对应多个地址,但是通过这个来检索出没有地址登记的用户。