Skip to main content


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 UguesFriend
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 SutherlandFriend
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 Apr 18 09:34:40 GMT 2024

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

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

Back to the top