3
加载实体不工作时,我有3类:休眠enableFilter通过ID
Event
PublicEvent extends Event
PersonalEvent extends Event
我的Hibernate映射文件就像波纹管出头。我想为PersonalEvent
添加一个过滤器,并在加载此对象之前,我已启用这是过滤器。但这不起作用。我的休眠版本是4.3.11.Final
。
Event.hbm.xml
<hibernate-mapping>
<class name="org.calendar.Event">
...
<filter name="personalEventAuthorize" condition="person_ID = :personId" />
</class>
<joined-subclass name="org.calendar.PersonalEvent" extends="org.calendar.Event">
<key column="id" property-ref="id" />
...
<many-to-one name="person" column="person_ID" entity-name="org.person.Person" />
</joined-subclass>
<joined-subclass name="org.calendar.PublicEvent" extends="org.calendar.Event">
<key column="id" property-ref="id" />
...
</joined-subclass>
<filter-def name="personEventAuthorize">
<filter-param name="personId" type="integer" />
</filter-def>
</hibernate-mapping>
PersonalEventRepository
@Override
public PersonalEvent load(Long id) {
Filter filter = getSession().enableFilter("personEventAuthorize");
filter.setParameter("personId", getAuthenticatedPersonId());
return super.loadById(id);
}
Hibernate生成的SQL查询没有我的过滤器。我的问题是什么?为什么hibernate无法为联合子类启用筛选器? 感谢所有...
感谢您的重播。在现在我使用这种方法.. –
这个问题似乎只存在于'joined-subclass' ..! –