users@glassfish.java.net

JPA Problem

From: <glassfish_at_javadesktop.org>
Date: Wed, 26 Dec 2007 05:39:28 PST

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