Yep, the database will never see a null value, but a new entity needs null id to differentiate it from an entity with 0 id. If you tell Hibernate to auto-gen the id with HSQLDB then the first row will have 0 id.

Geoff

On 10/02/2009, at 8:33 PM, Ville Virtanen wrote:


Sometimes if you want to assign the id an not let the DB do it for you it is good to be able to have null values. Also checkin whether the object is
already saved can be achieved by just checking id != null.

Primitive int defaults to zero without initialization?

- Ville


Ulrich Stärk wrote:

Thiago H. de Paula Figueiredo schrieb:
Em Mon, 09 Feb 2009 22:35:52 -0300, Luther Baker <lutherba...@gmail.com >
escreveu:

Simply stated, I'm asking about the two orthogonal choices: (native vs
object, range or size)
Is an int preferred to an Integer? Is there a compelling argument for
either native or Object?

I guess that you mean "primite" when you mean "native".
Native types in Java can't have null values, so, for primary key
properties, a Integer is a much better fit than an int.

Why is that? I couldn't imagine a case where you want your primary key
value to be NULL (apart from the fact that I don't know any DBMS that
allows that).

Uli

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org




--
View this message in context: 
http://www.nabble.com/Hibernate-ID-tp21926024p21930330.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to