-->
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: Problem with oneToMany relation
PostPosted: Thu Jan 05, 2012 10:04 am 
Newbie

Joined: Fri Aug 15, 2008 3:33 am
Posts: 17
Hi,

in my project I am using the hibernate 3.3.2 and the JPA implementation.
I have a problem with oneToMany relations which I will try to describe briefly.
There are 3 tables: A, B and C with a 1 to m relation from A to B and a 1 to n relation from A to C. I am using Oracle 10 g and the relations are created with the help of foreign keys. In the code the relations are specified with the help of oneToMany and manyToOne annotations.
for example:
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "a_id") - in class A twice (for B and C)

and @ManyToOne(fetch = FetchType.LAZY, optional=true)
@JoinColumn(name = "a_id", unique=true)
in B and C.

The problem is: when an object a is generated then are b x c elements in every list, which means internally hibernate makes a join over all 3 tables based on a_id. But there is no relation between B and C and the elements are independent from each other.

Is this a known behaviour? Or is there any solution for generating only the necessary lists?


Top
 Profile  
 
 Post subject: Re: Problem with oneToMany relation
PostPosted: Tue Jan 10, 2012 7:51 am 
Newbie

Joined: Tue Jan 10, 2012 7:15 am
Posts: 1
mitroiasi wrote:
Is this a known behaviour? Or is there any solution for generating only the necessary lists?

I don't know of any such a solution


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.