This content has been marked as final.
Show 1 reply
-
1. Re: mapping 0..1 association
alexg79 Nov 8, 2006 11:54 AM (in response to arvindsj)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; } ... }