Reputation: 31
How can you add greater than or less than symbols to the condition on a Hibernate filter specified in the hbm.xml file?
I am trying to add a filter to limit the collection to a specific date range:
<filter name="limitTalksByDateRange" condition="talkstart >= :tstart and talkstart <= :tend" />
Unfortunately this breaks the XML parsing. I've tried backslash-escaping, "ge" and "le" and even "between :tstart and :tend" which is mentioned in the Hibernate documentation. None has worked, and I'll be damned if I can find any documentation whatsoever that specifically delineates the valid operators in the filter condition.
Upvotes: 1
Views: 5703
Reputation: 31
I've found that this works:
<filter name="limitTalksByDaterange" condition="talkstart >= :tstart and talkstart <= :tend" />
I think the #nn codes might be a bit more reliable; I've seen > and < break in certain contexts.
I wasn't able to make the between construct work at all.
Upvotes: 0
Reputation: 192005
Did you try:
<filter name="limitTalksByDateRange" condition="talkstart >= :tstart and talkstart <= :tend" />
Note the >
and <
instead of the >
and <
.
Also, the examples that I saw did not have the ':
' on the limit variables, so perhaps this:
<filter name="limitTalksByDateRange" condition="talkstart >= tstart and talkstart <= tend" />
or this:
<filter name="limitTalksByDateRange" condition="talkstart BETWEEN tstart and tend" />
would work better.
Upvotes: 2