What are derived properties

What are derived properties

Answer: Hibernate derived property is a feature that are by definition is read only. This property value gets calculated at load time. For example declare the calculation as SQL expression then the expression will be translated into a select clause sub-query in SQL query which loads an instance. Below is example where finalPrice is derived property:

<property name="finalPrice" formula="( SELECT SUM (i.quantity*p.price) FROM item i, Product p WHERE i.productId = p.productId)"/>

Leave a Reply

Your email address will not be published. Required fields are marked *