I have an entity with a property "quantity", this value is not a table field but is dynamically calculated with an hql query.
So, is possibile to add this value in my entities and make hibernate calculate it when I load my entities?
You an use formula annotation. for example:
@Formula("(select min(o.creation_date) from Orders o where o.customer_id = id)")
private Date firstOrderDate;
See this post: Calculated property with JPA / Hibernate
Se also Hibernate tutorial: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/mapping.html#mapping-column
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With