-->
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: One to Many & MAny to One Foreign table
PostPosted: Mon Apr 21, 2008 11:32 am 
Newbie

Joined: Mon Apr 21, 2008 11:26 am
Posts: 1
HI!
I am new to Hibernate. Now here is situation what I am trying to do using Hibernate (Annotation).
Situation: I have one Abstract Class say A which i dont want to make Persistance. And it has some get and set method. Now I have extended from this Abstract Class say B. Now there is one more class C. Now B and C has relation one to many and many to one. So when i make entry in B or C one foreign table should be create (first time) and all relational entry should be there in this table. So can any body tell how can i achive this.

I will very thank full if any one send example as well.


Top
 Profile  
 
 Post subject: pls review the hibernate docs
PostPosted: Thu Apr 24, 2008 3:39 am 
Senior
Senior

Joined: Sun Jun 11, 2006 10:41 am
Posts: 164
Hi,
Did you look at the examples in Hibernate docs for one-to-many relationships? Also look in the JEE 5 tutorial chapter 24: introduction to JPA
http://java.sun.com/javaee/5/docs/tutorial/doc/

A few things you must always answer before deciding the nature of a relationship:

1. how will a user create a new A object? will it first be created without B's and then later you will add them? will A be created when it already has some B's associated to it? maybe both options are needed?

2. what happens when A is removed? will all its B's also be removed?

3. will you allow 2 users to concurrently update 2 different B's that "belong" to the same A object?

4. how are the various classes derived from your abstract class mostly expected to differ? in their logic? in their data members?

5. Will your database also be accessible from non-JPA code?


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.