users@glassfish.java.net

Re: _at_OneToOne(optional = false, ...) allows to save object with a null referenc

From: <glassfish_at_javadesktop.org>
Date: Fri, 21 Nov 2008 12:11:04 PST

For the optional tag, The JPA 1 Spec states:
  "(Optional) Whether the value of the field or property may be null. This is a hint and is disregarded for primitive types; it may be used in schema generation."

It is optional (most hints are), but TopLink/EclipseLink will use the tag for schema generation - relying on the database to do validation if it is required. If you used schema generation for your tables, you'd see they were created with the not-null constraint.

Best Regards,
Chris
[Message sent by forum member 'chris_delahunt' (chris_delahunt)]

http://forums.java.net/jive/thread.jspa?messageID=318178