Skip to content

Commit 568e385

Browse files
committed
discuss persistent identity in the javadoc
1 parent 51ebf1c commit 568e385

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

hibernate-core/src/main/java/org/hibernate/Session.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,17 @@
4444
* {@code Session}.
4545
* </ul>
4646
* <p>
47-
* At any given time, an instance may be associated with at most one open session.
47+
* Each persistent instance has a <em>persistent identity</em> determined by its type
48+
* and identifier value. There may be at most one persistent instance with a given
49+
* persistent identity associated with a given session. Normally, a persistent identity
50+
* is assigned when an {@linkplain #persist(Object) instance is made persistent}, but
51+
* when the entity identifier is {@linkplain org.hibernate.generator.OnExecutionGenerator
52+
* generated by the database}, assignment of the persistent identity is delayed until
53+
* the state of the entity is actually inserted in the database.
54+
* <p>
55+
* An instance of an entity class may be associated with at most one open session.
56+
* Distinct sessions represent state with the same persistent identity using distinct
57+
* persistent instances of the mapped entity class.
4858
* <p>
4959
* Any instance returned by {@link #get(Class, Object)}, {@link #find(Class, Object)},
5060
* or by a query is persistent. A persistent instance might hold references to other
@@ -59,8 +69,8 @@
5969
* <p>
6070
* A transient instance may be made persistent by calling {@link #persist(Object)}.
6171
* A persistent instance may be made detached by calling {@link #detach(Object)}.
62-
* A persistent instance may be marked for removal, and eventually made transient, by
63-
* calling {@link #remove(Object)}.
72+
* A persistent instance may be marked for removal, and eventually made transient,
73+
* by calling {@link #remove(Object)}.
6474
* <p>
6575
* Persistent instances are held in a managed state by the persistence context. Any
6676
* change to the state of a persistent instance is automatically detected and eventually

0 commit comments

Comments
 (0)