-->
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.  [ 3 posts ] 
Author Message
 Post subject: Can Components contain one-to-many bidirectional mapping
PostPosted: Sun Jan 15, 2012 2:05 am 
Newbie

Joined: Sat Jan 14, 2012 7:12 am
Posts: 7
FOlks,

I have a componentA which belongs to ClassA

I want to put a one-to-many mapping from componentA to ClassB

Hibernate allows me to put a mapping in componentA to ClassB.

However, I can not make the reverse happen.

What is the correct method to handle this situation?

Regards,


Shrivallabh


Top
 Profile  
 
 Post subject: Re: Can Components contain one-to-many bidirectional mapping
PostPosted: Mon Jan 16, 2012 4:28 am 
Newbie

Joined: Mon Jan 09, 2012 11:49 am
Posts: 3
can you paste your code?

i did it with the jpa annotation and it works (I think it works! :-D )


Top
 Profile  
 
 Post subject: Re: Can Components contain one-to-many bidirectional mapping
PostPosted: Mon Jan 16, 2012 7:45 am 
Newbie

Joined: Sat Jan 14, 2012 7:12 am
Posts: 7
@Entity
public class ClassA implements java.io.Serializable {

ComponentC componentC;

@Embedded
public ComponentC getComponentC()
{
return componentC;
}

public void setComponentC(ComponentC componentC)
{
this.componentC=componentC;
}

}

@Embeddable
public class ComponentC implements java.io.Serializable {

Set<ClassB> classBs;

@OneToMany
public Set<ClassB> getClassBs()
{
return classBs;
}

public void setClassBs(Set<ClassB> classBs)
{
this.classBs=classBs;
}

}


@Entity
public class ClassB implements java.io.Serializable {

ComponentC componentC;

@ManyToOne
public ComponentC getComponentC()
{
return componentC;
}

public void setComponentC(ComponentC componentC)
{
this.componentC=componentC;
}

}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.