-->
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.  [ 3 posts ] 
Author Message
 Post subject: Lazy loading problem
PostPosted: Fri Aug 13, 2010 11:14 am 
Newbie

Joined: Thu Mar 25, 2010 11:58 am
Posts: 4
Hi All,
I have a PO table for purchase details which contains a column for storing carrier. I store carrier id in the column and this can be null because some PO may not have carrier. I have created entity PO as shown below. When I try to display the list of PO I am getting an error javax.persistence.EntityNotFoundException: Unable to find...

When i debug my List I found if the carrier field in is null (it actually not null it ' ' single space in table and something like java_assist_12... in PO object). Then I tried to print this value in my Action class I found when i call say po.carrier.name an exception is occurring.

If I remove fetch = FetchType.LAZY then I could not get any result. I don’t understand why it is not working in either case.

Anybody have any idea. I believe foreign key in table can be null.

Code:

public class Po implements java.io.Serializable{
.
.


private Carrier carrier = new Carrier();

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns ({
       @JoinColumn(name="LOC",nullable=true, referencedColumnName = "LOC", insertable=false, updatable=false),
        @JoinColumn(name="CARRIER",nullable=true, referencedColumnName = "CARRIER", insertable=false, updatable=false)
})
public Carrier getCarrier() {
    return this.carrier;
}

.
.
.}


Please Help
Fabian


Top
 Profile  
 
 Post subject: Re: Lazy loading problem
PostPosted: Wed May 18, 2011 4:15 pm 
Newbie

Joined: Thu Mar 25, 2010 11:58 am
Posts: 4
fjkjava wrote:
Hi All,
I have a PO table for purchase details which contains a column for storing carrier. I store carrier id in the column and this can be null because some PO may not have carrier. I have created entity PO as shown below. When I try to display the list of PO I am getting an error javax.persistence.EntityNotFoundException: Unable to find...

When i debug my List I found if the carrier field in is null (it actually not null it ' ' single space in table and something like java_assist_12... in PO object). Then I tried to print this value in my Action class I found when i call say po.carrier.name an exception is occurring.

If I remove fetch = FetchType.LAZY then I could not get any result. I don’t understand why it is not working in either case.

Anybody have any idea. I believe foreign key in table can be null.

Code:

public class Po implements java.io.Serializable{
.
.


private Carrier carrier = new Carrier();

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns ({
       @JoinColumn(name="LOC",nullable=true, referencedColumnName = "LOC", insertable=false, updatable=false),
        @JoinColumn(name="CARRIER",nullable=true, referencedColumnName = "CARRIER", insertable=false, updatable=false)
})
public Carrier getCarrier() {
    return this.carrier;
}

.
.
.}


Please Help
Fabian


Top
 Profile  
 
 Post subject: Re: Lazy loading problem
PostPosted: Thu May 19, 2011 8:43 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Is the foreign key in your table ' ' instead of null? If yes, that is the problem and it seems like you did not define a foreign key constraint on the database, did you?

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.