Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to make @Formula annotation lazily loaded?

I have used @Formula annotation to use it for getting calculated properties. What I need is that those fields/getters which is annotated with @Formula annotation should be lazily loaded.

Is this even possible and if so how?

thanks

like image 236
destan Avatar asked Apr 09 '12 07:04

destan


1 Answers

Yes . Just annotating the fields/getter of the @Formula property by @Basic(fetch=FetchType.LAZY) and use this ant task provided by hibernate to do the bytecode instrumentation for the entity class. Otherwise , LAZY loading for the @Formula property is silently ignored.

The documentation contains the info on how to use this ant task to do bytecode instrumentation.

like image 154
Ken Chan Avatar answered Sep 18 '22 08:09

Ken Chan