-->
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.  [ 1 post ] 
Author Message
 Post subject: Problem with lazy loading
PostPosted: Fri Jan 14, 2011 8:49 am 
Newbie

Joined: Fri Jan 11, 2008 3:25 pm
Posts: 7
Hi all,

I have a problem, my code is:

@Entity
public class A{

@ManyToOne(fetch = FetchType.LAZY, targetEntity = B.class)
@JoinColumn(name = "b_id")
public B b;

}

@Entity
public class B{

private String id;
private String description;

}

I have a service method:

public A XXX(A a){

//Search Entity
A oldA= this.findById(a.getId())

//Load Entity
this.loadA(oldA);//FROM A LEFT JOIN FETCH a.b WHERE A.id=:id

}

In the method loadA is where I have the problem because doesn´t load the property and then when I access a.getB().getDescription() throw LazyInitializationException.

I don´t understand because no load the property. Any suggestion???

Thank you in advance


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

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.