Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Detached /transient objects

 
karimkhan pathan
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
can you please answer the following question .
I know hibernate will have a versioning ,if versioning is not available then
How does Hibernate distinguish between transient and detached objects?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
karimkhan pathan wrote:hi,
can you please answer the following question .
I know hibernate will have a versioning ,if versioning is not available then
How does Hibernate distinguish between transient and detached objects?


Between/ Not sure what you mean. But any object not managed by Hibernate is detached, whether it was loaded before by Hibernate, created with the new keyword, or retreived outside Hibernate. a Transient object is one without an id set. When a transient object is attached to Hibernate Session, and has no ID, when saved Hibernate will do an insert.

Basically, versioning is unrelated to detached/transient objects.


Mark
 
Pradeep Kumar
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, versioning has nothing to do with transient or detached. Hibernate can determine by looking into the id value of the entity. If its transient id value will not be set and if its set its a detached object. Versioning will come into picture during optimistic locking where we speicy with the <version> tag.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic