Hi Michael, It works exactly as you explained. I didn't spot that difference between optional and nullable before.
Thanks. On 13 juil. 2010, at 20:09, Michael Dick wrote: > > Hi Jean-Baptiste, > > I think what you want is > @Column(nullable=false) instead of marking it as optional=false. > > There's some blurring of the lines in OpenJPA, but generally @Column should > be used to indicate database constraints, and the @ManyToOne annotation for > ORM behavior. > > @Column will be used when OpenJPA generates table and to keep track of the > database schema internally. So nullable=false generates a DB constraint when > you use the mapping tool / synchronize mappings. > > The relationship annotations (@MtoO, @MtoM, etc) are used to validate the > contents of an entity at runtime. Optional=false tells OpenJP to make sure > there is a valid entity on the other side of the relationship before > persisting, updating. > > TL;DR : use @Column to indicate database constraints. > > Hope this helps, > -mike > > > > > -- > View this message in context: > http://openjpa.208410.n2.nabble.com/ManyToOne-not-optional-nullable-tp5287827p5288851.html > Sent from the OpenJPA Users mailing list archive at Nabble.com.
