-->
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: many-to-one + lazy initialization + not-found
PostPosted: Thu Oct 18, 2007 5:02 pm 
Newbie

Joined: Sun May 06, 2007 9:42 am
Posts: 7
Hello all,

After searching and reading so many posts here regarding the issue
of many-to-one association + lazy initialization + not-found=ignore,
I still can't understand if there is a solution for the problem.

As I see it I have only 2 options:

1) suffer from unneeded queries to be run when hitting an non existing association.

2) removing the not-found=ignore, and have a try/catch for
NotFoundObjectException surrounding my code,
when im trying to call the getter function.
If an exception is caught I set my member with a new empty instance so when the getter function will be called again, no query will be run (if the value was null, the query would run again).

Am I correct or is there a 3rd way?

My mapping
======================

Class Person {

@Id
@Column(name="P_ID")
public Long getId() {return id;}

@ManyToOne
@JoinColumn(name="NOTE_ID", insertable=false, updatable=false)
@LazyToOne(value=LazyToOneOption.NO_PROXY)
@NotFound(action=NotFoundAction.IGNORE)
public Note getNote() {return Note}
}

Class Note {
@Id
@Column(name="NOTE_ID")
public Long getId() {return id;}
}

My databse:
========

Table PERSON
-----------------
P_ID NOTE_ID

Table Note
-------------
NOTE_ID



Many thanks,

Barak


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 19, 2007 12:48 pm 
Newbie

Joined: Sun May 06, 2007 9:42 am
Posts: 7
any one?

Am I correct and these are my only options?


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.