-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: default-lazy setting with Annotations?
PostPosted: Mon Mar 03, 2008 11:20 am 
Newbie

Joined: Mon May 14, 2007 5:49 am
Posts: 17
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 05, 2008 2:52 pm 
Newbie

Joined: Mon May 14, 2007 5:49 am
Posts: 17
Maybe it's possible to set the default lazy in my hibernate config file.

It look like this:

Code:
<hibernate-configuration>
   <session-factory>
      <mapping class="my.package.business.objects.Competition"/>
      <mapping class="my.package.business.objects.User"/>
   </session-factory>
</hibernate-configuration>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.