-->
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: Problems with @OneToMany dual mapped.
PostPosted: Thu Sep 23, 2010 4:32 pm 
Newbie

Joined: Thu Sep 23, 2010 4:23 pm
Posts: 1
Hi everybody,

I have the following problems.
I have to create a database with relationship between class wich needs more than one level of bidirectional @OneToMany relationship.

For example:
Class A has one list of Class B and Class B has one list of Class C.

How Can I do this ?

I tried but found erros:
Exception in thread "main" org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: br.com.testhibernate.ClassC.ClassB in br.com.testhibernate.ClassB.ClassC_List


Top
 Profile  
 
 Post subject: Re: Problems with @OneToMany dual mapped.
PostPosted: Sat Sep 25, 2010 2:21 am 
Newbie

Joined: Wed Jun 18, 2008 9:17 am
Posts: 12
hi
Here is a very simple example for OneToMany:

Code:
@Entity
public class A {
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Integer id;
    @OneToMany(mappedBy="a",cascade=CascadeType.ALL)
    private List<B> blist = new ArrayList<B>();



Code:
@Entity
public class B {
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Integer id;
    @ManyToOne
    private A a;


Code:
create table A(id int not null primary key auto_increment);
create table B(
id int not null primary key auto_increment,
a_id int not null
);


repeat the similar mapping on B for C entity.

Hope this helps


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.