-->
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 multiple many relationship
PostPosted: Fri May 13, 2011 5:35 am 
Newbie

Joined: Fri May 13, 2011 5:28 am
Posts: 2
Consider two tables as mentioned below -
Table1 (id_col, name_col)
Table2 (uid_col, code_col_1, code_col_2)

where,
id_col is primary key for Table1
uid_col is primary key for Table2
and, id_col has one to many relationship with both code_col_1 and code_col_2

Records could look like:-
Table1
1, xxx
2, yyy

Table2
11, 1, 2
12, 2, 1
12, 2, 2

How will the JPA look like in following classes?

Code:
@Entity
@Table(name = "Table1")
public class T1 {
    @OneToMany(targetEntity=T2.class, mappedBy="??????", cascade=CascadeType.ALL)
    private List<T2> t2; //???not sure about this
}

@Entity
@Table(name = "Table2")
public class T2 {
    @ManyToOne
    @JoinColumn(name="code_col_1")
    private T1 t1;  //???not sure what goes here
}


Top
 Profile  
 
 Post subject: Re: one to multiple many relationship
PostPosted: Mon May 16, 2011 3:32 am 
Newbie

Joined: Fri May 13, 2011 5:28 am
Posts: 2
http://stackoverflow.com/questions/5989430/one-to-multiple-many-relationship


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.