开发者

Default conditions on Hibernate filters

I'm defining a Hibernate filter which specifies a default condition as follows:

<filter-def name="IsDeletedFilter" condition="IsDeleted = 'false'" />

Within my entity ma开发者_如何学运维pping, I associate the filter like this:

<filter name="IsDeletedFilter" />

According to the documentation, the filter should apply the default condition when used this way. When I try to do this, however, Hibernate throws a NullPointerException when it tries to parse the entity mapping. The stack trace shows this:

Caused by: java.lang.NullPointerException at org.hibernate.cfg.HbmBinder.parseFilter(HbmBinder.java:2957)

If, however, I specify the condition directly in the entity mapping like this:

<filter name="IsDeletedFilter2" condition="IsDeleted = 'false'"/>

it works fine and the data is getting filtered correctly.

What's the right way to use default conditions?


It's a bug. The possible walkaround is to define filters in another file, and include it. http://opensource.atlassian.com/projects/hibernate/browse/HHH-2488

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜