Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Workaround for Null Default Values

No way that I know of.  You can use a ReturningPolicy to omit an insert field
and select it back, but nothing to omit it only if null.  Perhaps log an
enhancement request.

In general it may be better to initialize the value in Java instead of the
database.  Even if you omit the null, you still don't get the value back
from the database, so your object becomes inconsistent with the database.

You might be able to hack something with a InsertObjectQuery Redirector on
the DescriptorQueryManager, but that would be complicated.



Tim Hollosy wrote:
> 
> This has probably been asked before, but I couldn't find it. Is there
> an easy way to make EclipseLink not include nulls in insert
> statements? As is, it's including the null value, which is causing the
> default value on in oracle to not be set.
> 
> I don't want to use the insertable=false attribute on the @Column
> annotation, because sometimes I want to be able to specify the value.
> 
> Basically I want an attribute that's like, includeWhenNull=false ,
> which when set would cause the column to be left out of the insert
> query.
> 
> I thought nullable=false might take care of it, but it didn't.
> 
> Thanks,
> Tim
> 


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/Workaround-for-Null-Default-Values-tp20980805p21060826.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top