Hello,
i have a little problem with lazy-loading and annotations. I have a application similar to the
petclinic example application.
But: I work with annotations to map the business modell to the database instead of the XML mapping in the petclinic example.
However. I have the following method in every business object:
Code:
@Transient
public boolean isNew() {
return (this.id == null);
}
And with this method i have a problem. I get the following error in my application:
javax.el.ELException: Error reading 'new' on type my.package..business.objects.User$$EnhancerByCGLIB$$cc715c48
javax.el.BeanELResolver.getValue(BeanELResolver.java:66)
...
org.hibernate.LazyInitializationException: could not initialize proxy - no Session org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
...
So ... ok ... i look in the petclinic example and see in the hibernate mapping file the follwing setting:
Code:
<hibernate-mapping auto-import="true" default-lazy="false">
default-lazy=false ... so ...
now THE question: How can i set the
default-lazy to
false with
Annotations?
The configuration (application-context, app-servlet) and DAOs in my application are very similiar to the configuration and DAO in the petclinic application. So .. i think with
lazy = false setting i can solve my problem.
Can anyone help me?
Thank you in advance.
Best regards,
Oliver