Actually these two are very good questions:
How Hibernate differs transient and detached entities?
Check for detached entity in Hibernate
I have actually read this many time, and check some posts in stackoverflow. A lot of answers are just copied from the persistence state definition without further explanation.
Let see the example below:
Person person = new Person();
person.id = 123; // 123 identifier exist in database.
person.name = "abc";
Hibernate doc state that for a transient
instance, it must be:
- instantiated using the new operator
- has no persistent representation in the database
- no identifier value has been assigned
This doesn't look like a transient instance, it doesn't fulfill the definition.
It doesn't look like a detached instance too, obviously it is not detached from a closed session.
So, is this a transient or detached instance?