On Wed, Aug 29, 2012 at 10:43 AM, Daniel Vashchilenko
<dan.vashchilenko@xxxxxxxxx> wrote:
@JoinColumn(name = "idkey_atd", nullable = true)
@ManyToOne(optional = false)
Just another user here. Usually you want to line up your optional and nullable attributes—normally if the @JoinColumn's nullable attribute is true, then the @ManyToOne's optional attribute should be true as well.
It is true that you are supposed to be able to separate them—the optional attribute is indicating something about the relationship; the nullable attribute is indicating something about the underlying column. You could argue that EclipseLink is in some way correct here: it's seeing that this relationship is supposed to be non-optional, and so is doing the only thing it knows how to do to enforce that (namely adding a NOT NULL constraint to the column in question, regardless of what you've told it here with your "nullable = true" attribute value). I'm not sure if this is fully specified in the JPA specification.
(I've always thought that the intersection of @NonNull (from bean validation), optional and nullable is a reasonably confused mess. :-))
Not sure if this is a typo on your part or if you're truly expressing something here with the difference in these two attributes.
Best,
Laird