HQL中的或逻辑查询的问题

来源:百度知道 编辑:UC知道 时间:2024/05/23 14:57:48
HQL中的或逻辑查询的语法是from User u where u.id=1 or u.name='tom'吗? 有没有其它要注意的?
我写的下面的查询语句不知怎么查不出数据
from Biandiansb b where b.biandiansuo.fenduan.id=1 or b.kaibisuo.fenduan.id=1
昨晚发问题的时候时间有点紧没说清楚,表的结构是这样子的:
数据库中有四张表biandiansb, biandiansuo, kaibisuo, fenduan, 对应四个对象Biandiansb, Biandiansuo, Kaibisuo, Fenduan.
其中Biandiansuo和Kaibisuo的属于Fenduan下的两种平级机构,Biandiansb是属于Biandiansuo或Kaibisuo下的设备。
我是这样设计数据结构的:Biandiansuo和Kaibisuo都的一个Fenduan类型的成员,用来指明其是属于那个分段的。Biandiansb有一个Biandiansuo类型的成员和一个Kaibisuo类型的成员,若是属于Biandiansuo的设备,则对应的成员有值,另一个为null,反之亦然。
现在我想查询出某个分段下的所有设备(包括Biandiansuo和Kaibisuo的),我的HQL语句为:
from Biandiansb b where b.biandiansuo.fenduan.id=1 or b.kaibisuo.fenduan.id=1

HQL中的或逻辑查询的语法是from User u where u.id=1 or u.name='tom'吗? 有没有其它要注意的?
回答:是的.HSQL语法中包含了sql语法,所以象写sql那样的写法在hsql里都被支持.

我写的下面的查询语句不知怎么查不出数据
from Biandiansb b where b.biandiansuo.fenduan.id=1 or b.kaibisuo.fenduan.id=1
回答:如果biandiansuo和kaibisuo是b中引用的其他对象,而且确定该对象中有点后面的那个对象,就可以查询出数据来.

。。。
表结构是什么样滴啊。
hql就是吧表当成对象来看,下面那个语句应该是对的。
但是不知道你的表结构是什么样的。。