-->
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: how to define mapping if there is no relationship for tables
PostPosted: Thu Mar 23, 2006 4:18 am 
Newbie

Joined: Mon Feb 06, 2006 12:25 am
Posts: 17
HI,

I have two table. But there is no direct relationship between these tables.

But First table's primary column used in second table. Like parent and child.


so is there is anyway that i can define a relatioship in my mapping file eventhough there is no direct relationship.

thanks in advance
Balag


Top
 Profile  
 
 Post subject: Re: how to define mapping if there is no relationship for ta
PostPosted: Thu Mar 23, 2006 10:24 am 
Regular
Regular

Joined: Tue Nov 16, 2004 6:36 pm
Posts: 62
Location: Zürich
balag wrote:
HI,

I have two table. But there is no direct relationship between these tables.

But First table's primary column used in second table. Like parent and child.


so is there is anyway that i can define a relatioship in my mapping file eventhough there is no direct relationship.

thanks in advance
Balag


Hibernate does not rely on there being a real relationship in the database. If you want you can still define a relationship in hibernate.

However, without foreign key it is easily possible that your reference will point to a non-existent key, leading to an Exception on the hibernate side.

You can prevent an exception in this case and instead obtain a null reference if you specify <many-to-one ... not-found="ignore" />


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 23, 2006 1:47 pm 
Newbie

Joined: Mon Feb 06, 2006 12:25 am
Posts: 17
Hi Thanks,
i will try that.

hi you specified <many- to-one> that we used for child table.

what about <one-to-many> for parent table??


can i leave that one-to-many in first table, and i can specify many-to-one in second table(child).??


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.