Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java int primitive type to database null???

77521Aug 14 2003 — edited Feb 8 2006
I am running Toplink 9.0.3.4 and have noticed that setting the "Use Default Value When Database Field is Null" does not seem to work. If I check this on an attribute that is of type int in the java class and number in the database, and set the value to 0, I am still getting 0 on insert and update. Here is what I am trying to get working.

given a java class with an int attribute:
public class A
{
private int A = 0;
public int getA() { return this.A };
public void setA(int A) { this.A=A; }
}

table A
(
id number not null primary key
A number
)

What I want is if I do not initialize A to anything
other than 0, I want a null inserted into table A
for column A. If I initialize it to something other than 0, for example 1, I want 1 inserted in to A for column A. I want to be able to set column A in table A
back to null by initializing attribute A in class A back to 0.

So far setting the above flag and value on the descriptor does not work, nor set DatabaseLogin.setDefaultNullValue(). In all cases 0
gets inserted into the database even when I tell it to
use 0 as default value for null.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 8 2006
Added on Aug 14 2003
7 comments
1,715 views