Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Specifying greater than/less than in Hibernate filters  RSS feed

 
craig hollinshead
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can greater than or less than symbols be added 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.
 
craig hollinshead
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the ASCII escape codes (&#62; for greater than, &#60; for less than) will fix the XML incompatibility with the greater/less than signs in the filter:

<filter name="limitCategoryTalksByDaterange" condition="talkstart &#62;= :tstart and talkstart &#60;= :tend" />
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!