• Post Reply Bookmark Topic Watch Topic
  • New Topic

about Entity instance lifecycle

 
vitesse wei
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
third question about Entity's lifecycle,give answer is D,how about B and C,can anyone explain those two statements.thanks

Which statement about an entity instance lifecycle is correct?
A. A new entity instance is an instance with a fully populated state.
B. A detached entity instance is an instance with no persistent identity.
C. A removed entity instance is NOT associated with a persistence context.
D. A managed entity instance is the instance associated with a persistence context.
 
Adam Tkaczyk
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A is not good because entity is in "new" state after statement
EntityClass object = new EntityClass();
so it can have no state available (no persistence identity also)

B is not good because "detached" state means that entity is no longer available in persistence context, but it was before, so it has persistence identity

C is not good because "removed" entity is still associated with persistence context because the persistence context has to make database operations to physically remove db row from database.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!