| Null Property persisted with value Zero [message #639638] |
Wed, 17 November 2010 05:15  |
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  |
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
|
|
|
Powered by
FUDForum. Page generated in 0.01554 seconds