[jboss-user] [EJB/JBoss] - Re: mapping 0..1 association
alexg79
do-not-reply at jboss.com
Wed Nov 8 11:54:43 EST 2006
anonymous wrote : I tried using OneToMany annotation along with nullable set to true, but that doesn't work.
Associations are "optional" by default.
To enforce 1..* or 1..1 associations, you'd have to do:
@ManyToOne(optional = false)
What exactly isn't working? Are you using the "mappedBy" property correctly?
Example:
| @Entity
| public class A {
| ...
| @OneToMany(mappedBy = "myA")
| public List<B> getBList() {
| return bList;
| }
| ...
| }
|
| @Entity
| public class B {
| ...
| @ManyToOne
| public A getMyA() {
| return myA;
| }
| ...
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3984235#3984235
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3984235
More information about the jboss-user
mailing list