webtier@glassfish.java.net

Re: 'Attempt to modify an identity column' exception (no Hibetnate)

From: <webtier_at_javadesktop.org>
Date: Wed, 15 Jul 2009 07:08:41 PDT

Thanks!
@GeneratedValue(strategy=GenerationType.IDENTITY) works.

I have one more tricky question.
The [i]status[/i] column in my database is defined:

status varchar(8) not null default 'INACTIVE'

when I try to persist:
[i]User u = new User(email, password);[/i]

I get:

[i]Column 'STATUS' cannot accept a NULL value.
Error Code: -1
Call: INSERT INTO FX.OOF_USERS (EMAIL, PASSWORD, STATUS) VALUES (?, ?, ?)
        bind => [2, 2, null][/i]

When I add @Transient to this field in the User entity class it works fine.
However, I would like to use User.setStatus(String status) later on. With the status field set to transient it has no effect.

Is it possible to make the container omit the null status value in the insert statement leaving the functionality of the setStatus method intact?
[Message sent by forum member 'dziku' (dziku)]

http://forums.java.net/jive/thread.jspa?messageID=355776