java - Lazy loading doesn't work for @Formula in Hibernate -
i'm trying make 1 of fields calculable, don't want calculate time entity retrieved. want, calculate in case it's necessary current query or time getter invoked. that's why use @formula: @basic(fetch = fetchtype.lazy) @formula("(select max(myentity.creation_time) myentity myentity myentity.account_id = id)") private localdatetime entitiesmodifieddate; to make work, use bytecode instrument this: <plugin> <artifactid>maven-antrun-plugin</artifactid> <version>1.3</version> <executions> <execution> <id>instrument domain classes</id> <configuration> <tasks> <taskdef name="instrument" classname="org.hibernate.tool.instrument.javassist.instrumenttask"> <classpath>