-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

There's actually no way - at least according to the documentation, my
own experience, and Google - to specify an unsaved-value using just
annotations. You'd have to use a mapping file for this. But apart from
that, Jonathan is spot on. :)

/Filip

On 2009-02-10 12:16, Jonathan O'Connor wrote:
> Uli,
> Using Object for key fields is a standard micro pattern in JPA and
> Hibernate. Of course, the DB does not want to save null as a key field
> value, but the most people get the entity manager to auto-generate keys
> for their objects.
> 
> By leaving the key as null, the entity manager knows that it needs to
> persist the object, generating a key for it. This is a handy pattern,
> when you want to create a parent object with several children, and then
> persist the whole object tree in one call (otherwise, you would have to
> persist the tree, one object at a time, from the bottom up - Yikes!).
> JPA/Hibernate can only do this if it knows what a null key value is, and
> in Java that is of course, null. I think (from memory) you can define a
> specific value as a null, so you could use an int or a long as a key
> field type, and then specify, for example, -999, as the null value.
> Then, you have to set the key field to -999 somewhere, and this is all
> too much work for most people, therefore, they use Object key field values!
> 
> Ciao,
> Jonathan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQEcBAEBAgAGBQJJkd4/AAoJEEfiH7PpjaMnoDwH/1SdtbIjF0uqxbqe8GJONrty
cYM5Y9Nyh7KTVrNCHaFd0me6TgTYUpjvZnwzIufIZmIA/pp05PcmhpoN2DLXbT/o
6Ixx+yFDQdO0RX2D7fUEk+Gtpl55pvZ63UMWNPbGZcqU1FOLaie6s1Qm9p0NYCmN
BcrXRtKDfkaJUN/ayKflukK3UAtkdpW25R183JsEOzncBkBB3XynTYQk0oWXcTEF
kmVz8+Ki9y+ZBPPDp/M+P+IkTK+DNw979uAUiaxHtPb0eueew9D365ewUpstKuxt
95K28mlpkKxwbQYXUHAC5buNJzMdro4bspGZ+UPwbUAg3vJ1WagLKuJYhCEytv8=
=jyxQ
-----END PGP SIGNATURE-----

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

Reply via email to