How to map a property for HQL usage only (in Hibernate)?

Posted by ManBugra on Stack Overflow See other posts from Stack Overflow or by ManBugra
Published on 2010-05-11T16:48:13Z Indexed on 2010/05/11 17:24 UTC
Read the original article Hit count: 216

Filed under:
|
|

i have a table like this one:

id | name | score

mapped to a POJO via XML with Hibernate. The score column i only need in oder by - clauses in HQL. The value for the score column is calculated by an algorithm and updated every 24 hours via SQL batch process (JDBC). So i dont wanna pollute my POJO with properties i dont need at runtime.

For a single column that may be not a problem, but i have several different score columns. Is there a way to map a property for HQL use only?

For example like this:

<property name="score" type="double" ignore="true"/>

so that i still can do this:

from Pojo p order by p.score

but my POJO implementation can look like this:

public class Pojo
{
  private long id;

  private String name;

  // ... 
}

No Setter for score provided or property added to implementation.

using the latest Hibernate version for Java.

© Stack Overflow or respective owner

Related posts about java

Related posts about hibernate