Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » @Embeddable object how to discriminate for an object with blank field
@Embeddable object how to discriminate for an object with blank field [message #669523] Tue, 10 May 2011 15:07 Go to next message
Massimo Ugues is currently offline Massimo Ugues
Messages: 10
Registered: January 2011
Junior Member
Hallo all.

I have an Embeddable object where every field is mapped to a CHAR column on DB.

When I have no data on DB eclipse-link recognizes this and does not instantiate the embeddable object.
But when I have some blank chars on one of the properties the object is created and every properties is defaulted to null (except the one with blank chars that is defaulted to "" since eclipselink trims the trailing blank).

Is possible to configure how eclipse-link should handle the creation of the embeddable object?

Kind regards
Massimo
Re: @Embeddable object how to discriminate for an object with blank field [message #670042 is a reply to message #669523] Thu, 12 May 2011 13:48 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

This can be configured on the AggregateObjectMapping using the setIsNullAllowed(false) API. This can be set using a DescriptorCustomizer on the Entity referencing the Embeddable.

false - will always create an empty instance, true - will use null if all of the field values are null.

If you need anything more complex than that, you could use property access for the mapping and in your set method check the values of the embedded object.



James : Wiki : Book : Blog : Twitter
Previous Topic:@AttributeOverrides gives me exception
Next Topic:How to convert a jpql filter condition to Expression
Goto Forum:
  


Current Time: Thu Oct 23 22:16:12 GMT 2014

Powered by FUDForum. Page generated in 0.13417 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software