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: owning side of a one to many
PostPosted: Fri Jul 14, 2006 2:20 pm 
Newbie

Joined: Sat Mar 11, 2006 4:15 pm
Posts: 15
Okay, I've got a class A which can 0 or more of class B. If I put a @OneToMany in A and a @ManyToOne in B then hibernate creates B as the "owning" side. My problem is that since B is the owning side I can't add to the list of B's in A and then save A and have the associated saved. What is the reason for this? Is there a way to be able to do this without having to create a join table? How can I add them to the collection and have the B's assocation saved without having to do something like B.setA(a) every time?

One solution is to remove the @ManyToOne on B which would persist the collection in A but would also create a join table. Also, I wouldn't be able to write a query like this: "from B b where b.a = :a" which I know I'm going to need to. How have other people gotten around this?


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.