Page 1 of 1

About Question enthuware.oce-jpad.v6.2.504 :

Posted: Fri Jun 01, 2012 2:43 am
by cosminvacaroiu
What's the difference of a new entity and a detached entity ? If for example the id isn't set as generated, it is written explicitly and the new entity has an Id set. How does he make the difference ?

Re: About Question enthuware.oce-jpad.v6.2.504 :

Posted: Mon Jan 07, 2013 3:11 pm
by study
• A new entity instance has no persistent identity, and is not yet associated with a persistence context.

• A detached entity instance is an instance with a persistent identity that is not (or no longer) associated with a persistence context.

Sect 3.2 of JSR317 Specification

Object identity does not equal Persistent identity

Re: About Question enthuware.oce-jpad.v6.2.504 :

Posted: Sun Jul 20, 2014 9:03 am
by ramy6_1
Hello ,

Regarding option two "If entityObject is already removed, IllegalStateException will be thrown."

I can't understand what is the difference between remove and detach , I think removing entity instance make it detached (Un managed by the PC).

Please explain

Re: About Question enthuware.oce-jpad.v6.2.504 :

Posted: Sun Jul 20, 2014 9:23 pm
by admin
Removing an entity means you are removing the corresponding data from the database. Detaching it means the instance is not managed anymore by the persistence context. Detaching doesn't affect the database.