Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nhibernate 在HQL where子句中使用对象的类型_Nhibernate_Hibernate_Hql - Fatal编程技术网

Nhibernate 在HQL where子句中使用对象的类型

Nhibernate 在HQL where子句中使用对象的类型,nhibernate,hibernate,hql,Nhibernate,Hibernate,Hql,在我的域模型中,我有一个抽象类CommunicationChannelSpecification,它有子类,如ftpcchannelspecification、EMailChannelSpecification和WebserviceChannelSpecification。现在我想创建一个HQL查询,其中包含一个where子句,该子句将结果缩小到特定类型的通道规范。例如,(用简单的英语)选择其类型出现在集合{FTPChannelSpecification,WebserviceChannelSpe

在我的域模型中,我有一个抽象类CommunicationChannelSpecification,它有子类,如ftpcchannelspecification、EMailChannelSpecification和WebserviceChannelSpecification。现在我想创建一个HQL查询,其中包含一个where子句,该子句将结果缩小到特定类型的通道规范。例如,(用简单的英语)选择其类型出现在集合{FTPChannelSpecification,WebserviceChannelSpecification}中的所有通信信道规范

如何在HQL中实现这一点?我正在使用NHibernate2.0.1和每个子类一个表的继承映射策略

谢谢


Pascal在NHibernate中不是阳性的,但在Hibernate中,有两个特殊属性总是被id和class引用。所以,对于你的特殊情况,我愿意

from CommunicationChannelSpecifications spec where spec.class in (?)

在本例中,NHibernate支持与Hibernate相同的语法。请参见示例。

答案不错,但如果我们想在更新(hql)中实现这一点,该怎么办。我的意思是更新实体,其中class=com.pa.SubEntity?