Gordon Yorke (EclipseLink Architecture Committee Member, TopLink Core Technical Lead, JPA 2.0 Expert Group Member) wrote a good answer on this topic so instead of paraphrasing him, I'll quote his answer:
The difference between optional
and
nullable
is the scope at which they
are evaluated. The definition of
'optional
' talks about property and
field values and suggests that this
feature should be evaluated within the
runtime. 'nullable
' is only in
reference to database columns.
If an implementation chooses to
implement optional
then those
properties should be evaluated in
memory by the Persistence Provider and
an exception raised before SQL is sent
to the database otherwise when using
'updatable=false
' 'optional
'
violations would never be reported.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…