Hi,

I am migrating an application from Glassfish/EclipseLink to WebSphere/OpenJPA 
2.2.2 and I have to following problem.
Eclipselink and OpenJPA handle "empty" Embeddables (i.e. Embeddables with all 
fields null) differently.
OpenJPA's default assumption is that an Embeddable is always "non-null", but 
EclipseLink does the opposite, meaning if all persistent members are null, the 
whole Embeddable is null.

The application heavily uses validation annotations on the members of the 
embeddables and @NotNull is one of them.
Now think of an entity that contains an embeddable which may be null. There is 
no problem in persisting the entity. There is also no problem when you try to 
load that entity from the database. But when you modify some attribute of the 
entity and OpenJPA tries to update it in the database, then you get a 
javax.validation.ConstraintViolationException because OpenJPA validated the 
"empty" embeddable it created when it loaded the entity from the database and 
there is a @NotNull annotation on a member of the embeddable which is now null.

I know this isn't a bug of OpenJPA since JPA does not specify what to expect 
when all members of an Embeddable are null.
But my question is: Is there a way to configure OpenJPA (globally) to behave 
like eclipselink in the case of "empty" embeddables, without the need to use 
OpenJPA specific annotations in the code like 
"@EmbeddedMapping(nullIndicatorColumnName="xyz")?
The java code has to be strictly JPA provider neutral, because the application 
(EAR) has to work on both platforms. Provider specific properties in 
persistence.xml or other configuration files, which don't interfere with 
EclipseLink would be okay.

Thanks for your help,
Tobias

_______________________________________________________________________
[Email_CBE.gif]Tobias Meyer
Custom Solution Development | Application Services

Capgemini | Hamburg
Phone: +4940254491291 - Mobile: +4915140250554
e-mail: tobias.me...@capgemini.com
www.de.capgemini.com<http://www.de.capgemini.com/>

Luebecker Strasse 128, D-22087 Hamburg, Germany
People matter, results count.
_______________________________________________________________________


________________________________

Firma: Capgemini Deutschland GmbH
Gesch?ftsf?hrer: Dr. Michael Schulte (Sprecher) * Dr. Uwe Dumslaff * Josef 
Ranner
Aufsichtsratsvorsitzender: Antonio Schnieder
Amtsgericht Berlin-Charlottenburg, HRB 98814
This message contains information that may be privileged or confidential and is 
the property of the Capgemini Group. It is intended only for the person to whom 
it is addressed. If you are not the intended recipient, you are not authorized 
to read, print, retain, copy, disseminate, distribute, or use this message or 
any part thereof. If you receive this message in error, please notify the 
sender immediately and delete all copies of this message.

Reply via email to