webtier@glassfish.java.net

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

From: <webtier_at_javadesktop.org>
Date: Thu, 16 Jul 2009 02:08:33 PDT

Of course it would :)

public User(String email, String password) {
this.email = email;
this.password = password;
this.status = 'INACTIVE';
}

or

...
User u = new User(email, password);
u.setStatus('INACTIVE');
em.persist(u);
em.flush();

both would work as well.

I just wanted to know how to make the container omit the value of the [i]status[/i] field in the entity while creating an insert statement. In this way I wanted to make the database itself insert the default value defined in the table definition. That's what the default values are defined for. There's no use defining a column with its default value when you still need to set this value in the entity.

I agree I'm being a pain in the a... but I'm just curious :)
[Message sent by forum member 'dziku' (dziku)]

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