Page 1 of 1

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

Posted: Fri Jun 01, 2012 9:32 am
by Guest
Why is A true !?

The question says:

A new entity instance is the one that has a corresponding row in the database table but is not synchronized with it. (this is not true as far as I know)

The explanation says:
A new entity instance is the one that does not have a corresponding row in the database table...

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

Posted: Sat Jun 09, 2012 1:52 pm
by admin
The question asks you to select wrong statements, that is why option 1 is correct.

HTH,
Paul.

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

Posted: Wed Jul 31, 2013 9:51 pm
by pagarciaortega
Hi,

for me the term 'new entity' is confusing, because that exact term is used to represents entities that have not been persisted yet.

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

Posted: Thu Aug 01, 2013 8:20 am
by admin
Yes, it is used in the same sense in option 1.
HTH,
Paul.

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

Posted: Tue Sep 18, 2018 11:24 pm
by __JJ__
A managed entity instance is the one that has a corresponding row in the database table and is also synchronized with it.
Is this not incorrect? I thought a managed entity is one that exists in the persistence context; it may or may not have a corresponding row in the database; it may or may not be synchronized with the db; as far as I am aware, synchronization with the db means committing:
3.2.4 Synchronization to the Database
The state of persistent entities is synchronized to the database at transaction commit. This synchronization
involves writing to the database any updates to persistent entities and their relationships as specified
above.
Furthermore AFAIK any entity may be managed by an extended PC that is not even connected to a transaction so quite possibly won't we anywhere near synchronized to the db, so why is it not possible for an entity to be managed but either not in the db or not synchronized with it?

em.find(someobj, 1L) => someobj is managed; change someobj; it's still managed, but it's not in synch with the db. So this sentence is wrong.
Or am I wrong?
Thanks.

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

Posted: Tue Sep 18, 2018 11:59 pm
by admin
As per section 3.2 of JPA Spec:
A new entity instance has no persistent identity, and is not yet associated with a persistence context.
A managed entity instance is an instance with a persistent identity that is currently 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.
A removed entity instance is an instance with a persistent identity, associated with a persistence context, that will be removed from the database upon transaction commit.