title: Having greater than or less than in hibernate named sql query
body: <p>I'm using hibernate 3 with named query in the hibernate configuration xml.</p>
  
  <p>The named query originally matched a date with the user entered date, and it worked fine.
  But when I changed the equals ('=') to a less than ('&lt;=') it gave me the following error.</p>
  
  <pre><code>Caused by: org.hibernate.MappingException: Could not parse mapping document in input stream
      at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:431)
      at org.hibernate.cfg.Configuration.addResource(Configuration.java:482)
      ... 106 more
  Caused by: org.dom4j.DocumentException: Error on line 57 of document  : The content of elements must consist of well-formed character data or markup. Nested exception: The content of elements must consist of well-formed character data or markup.
      at org.dom4j.io.SAXReader.read(SAXReader.java:482)
      at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:422)
      ... 107 more
  </code></pre>
  
  <p>This is because the XML parser does not allow '&lt;' or '>' inside the content of tags. But '&lt;' or '>' is necessary to form the &lt;= or >= comparison. Is there an alternate way to represent greater than or less than such that the parser is happy.</p>
  
  <p>NB: I already know we can put the named query as annotation in the code, but I prefer it this way for system consistency.</p>
  
  <p>Sample Named Query:</p>
  
  <pre><code>&lt;sql-query name="persons"&gt;
      &lt;return alias="person" class="eg.Person"/&gt;
      SELECT person.NAME AS {person.name},
             person.AGE AS {person.age},
             person.SEX AS {person.sex}
      FROM PERSON person
      WHERE person.NAME LIKE :namePattern
      AND trim(person.JOINDATE) &lt;= to_date(:joinDate, 'dd-mm-yyyy')
  &lt;/sql-query&gt;
  </code></pre>