Programming Tutorials

Formula in Hibernate

By: Dorris in Hibernate Tutorials on 2011-01-01  

Sometimes, you want the Database to do some computation for you rather than in the JVM, you might also create some kind of virtual column. You can use a SQL fragment (aka formula) instead of mapping a property into a column. This kind of property is read only (its value is calculated by your formula fragment).

@Formula("obj_length * obj_height * obj_width") public long getObjectVolume()

The SQL fragment can be as complex as you want and even include subselects.

Add Comment

* Required information


No comments yet. Be the first!

Most Viewed Articles (in Hibernate )

Latest Articles (in Hibernate)