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 05:15 Go to next message
Mauro Flores is currently offline Mauro Flores
Messages: 83
Registered: September 2009
Location: Brasil
Member
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 10:35 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1834
Registered: July 2009
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,
i.e.

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


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


Current Time: Sun May 19 07:26:32 EDT 2013

Powered by FUDForum. Page generated in 0.01554 seconds