users@glassfish.java.net

Re: JPA Problem

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Wed, 02 Jan 2008 15:16:51 -0800

Check if this blog describes your problem:
http://blogs.sun.com/marina/entry/reading_java_persistence_api_spec1

thanks,
-marina

glassfish_at_javadesktop.org wrote:
> Hi,
>
> i'm spanish and my english is not good, so i'll try write as well as i can...
>
> i'm doing a web aplication using Struts, java 6 and the topLink essential implementation to JPA.
>
> Basically there are two entities, Flats and his son entity, Property ("Inmueble" in Spanish). The problem appears when you insert many Properties (with his corresponding Flat), delete one of them, and inmediatly after you re-insert another flat. That's when say the exception: "java.lang.IllegalStateException: During synchronization a new object was found through a relationship that was not marked cascade PERSIST:com.dalya.bbdd.entity.Inmueble [idInmueble=5]."
>
> For insert, i do two save's, one for the Flat and the other for de Property in wich i've introduced the flat. we can introduced "n" Flat's and no problem never.
>
> To clear, I just erased the Property because this relationship is marked with a cascade deleted, so, the floor connected also clears. When we clear, nor is there any problem apparently becuse on the BBDD persist the flat's i've introduced least that has been erased.
>
> It is when we try to re-insert another floor when the exception jumps.
>
> I tried to stop the Tomcat server just after deleting the floor. When you lift it and try to insert can be no problem again.
>
> When jumps the exception, if again attempt to save the floor, then it is recorded in the BBDD smoothly.
>
> What did I do wrong??
>
> If you want to see the source code, said to me, and i'll send it.
> [Message sent by forum member 'alexcollado' (alexcollado)]
>
> http://forums.java.net/jive/thread.jspa?messageID=251441
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>