Skip to content

Commit 73392fb

Browse files
committed
add PersistenceUnitUtil.getVersion()
see jakartaee#74
1 parent 07c7579 commit 73392fb

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

api/src/main/java/jakarta/persistence/PersistenceUnitUtil.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,17 @@ public interface PersistenceUnitUtil extends PersistenceUtil {
163163
* to be an entity
164164
*/
165165
public Object getIdentifier(Object entity);
166-
}
166+
167+
/**
168+
* Return the version of the entity.
169+
* A generated version is not guaranteed to be available until after
170+
* the database insert has occurred.
171+
* Returns null if the entity does not yet have an id.
172+
* @param entity entity instance
173+
* @return id of the entity
174+
* @throws IllegalArgumentException if the object is found not
175+
* to be an entity
176+
* @since 3.2
177+
*/
178+
public Object getVersion(Object entity);
179+
}

spec/src/main/asciidoc/ch07-entitymanagers-and-persistence-contexts.adoc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,5 +1524,18 @@ public interface PersistenceUnitUtil extends PersistenceUtil {
15241524
* to be an entity
15251525
*/
15261526
public Object getIdentifier(Object entity);
1527+
1528+
/**
1529+
* Return the version of the entity.
1530+
* A generated version is not guaranteed to be available until after
1531+
* the database insert has occurred.
1532+
* Returns null if the entity does not yet have an id.
1533+
* @param entity entity instance
1534+
* @return id of the entity
1535+
* @throws IllegalArgumentException if the object is found not
1536+
* to be an entity
1537+
* @since 3.2
1538+
*/
1539+
public Object getVersion(Object entity);
15271540
}
15281541
----

0 commit comments

Comments
 (0)