How to map a property for HQL usage only (in Hibernate)?
- by ManBugra
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.