Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Null Property persisted with value Zero
Null Property persisted with value Zero [message #639638] Wed, 17 November 2010 10:15 Go to next message
Mauro Flores is currently offline Mauro FloresFriend
Messages: 84
Registered: September 2009
Location: Brasil
Is there a way to configure eclipselink in order to persist numeric properties with content NULL as column with value ZERO ?
That's a requirement of a legacy database/application.

Thanks, Mauro.
Re: Null Property persisted with value Zero [message #639981 is a reply to message #639638] Thu, 18 November 2010 15:35 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

The easiest way is to just change your object's type to a primitive, i.e. int instead of Integer, then it will never be null, or default the value in your constructor.

You could also configure a conversion for the specific mapping using a Converter. Or you could enable it for all mappings using a default null value for the type.

In a SessionCustomizer you can set the default null value,

session.getLogin().setDefaultNullValue(Integer.class, 0);

James : Wiki : Book : Blog : Twitter
Previous Topic:unexpected behavior using refreshAndLockObject
Next Topic:Is @PrimaryKeyJoinColumn(...) the same as...?
Goto Forum:

Current Time: Thu Apr 09 05:49:52 GMT 2020

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

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

Back to the top