Hi Jeff,

That was my first attempt. just before the persist method I was doing "
p.setId(null)"

That was enough for simple objets but fails if with complex objects that
have a collection inside.
If I add a new item to that collection I must to iterate and make a
"setId(null" again.

For that reason I was trying to set a global hibernate var that changes that
behaviour from null to 0.

Toplink does not have this problem and is works better with FDS2, but the
only one problem is with exceptions. When an toplink throws an exception we
have huge stack trace and FDS2 ends with a "channel disconnected" error.
This seems to be an error with toplink essentials.

So with hibernate we have the id problems and with toplink the exception
problem....very frustrating :(



On 1/19/07, Jeff Vroom <[EMAIL PROTECTED]> wrote:

   FDS needs a way to indicate that "0" on the client side means null on
the server… unfortunately that did not make it in 2.0.1 but I have it on
my list for the next release.   One workaround for this would be to extend
the assembler and override the createItem method.  If the id is 0 in that
class, just set it to null in the Java object.  I assume the Java object has
an "Integer" rather than an "int" so this is possible.



Jeff


 ------------------------------

*From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
Behalf Of *Carlos Rovira
*Sent:* Friday, January 19, 2007 1:23 AM
*To:* flexcoders@yahoogroups.com
*Subject:* [flexcoders] [FDS2+Spring/Hibernate] VOs reaching the backend
with id=0 ("unsaved-value" problem)



Hi,

I'm switching from Toplink to Hibernate using JPA/EJB3 and Annotations.
I'm facing a problem with this change due to the fact that when I try to
persist new entities Hibernate throws a "PersistenceObjectException:
Detached entity passed to persist". Hibernate expects new entities with ID =
NULL and my new entities reach the hibernate layer with ID = 0.

If I were using hibernate xml config files (hbm.xml) I could use
"unsaved-value = 0" (for each entity), but I'm using Annotations and there's
no "unsaved-value" annotation to use.

So, anyone reach this problem? How could I change the default
configuration in Hibernate so new entities with ID = 0 will be considered as
the default.

Or maybe there's a way in FDS2 to configure default value to null?

Thanks for any light on this :)

C.




--
::| Carlos Rovira
::| http://www.carlosrovira.com
::| http://www.madeinflex.com




--
::| Carlos Rovira
::| http://www.carlosrovira.com
::| http://www.madeinflex.com

Reply via email to