diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/mutiny/Mutiny.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/mutiny/Mutiny.java index 9bdf215f7..493c0ed03 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/mutiny/Mutiny.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/mutiny/Mutiny.java @@ -1877,6 +1877,17 @@ default Uni refresh(Object entity, LockModeType lockModeType) { */ Uni fetch(T association); + /** + * Return the identifier value of the given entity, which may be detached. + * + * @param entity a persistent instance associated with this session + * + * @return the identifier + * + * @since 3.0 + */ + Object getIdentifier(Object entity); + /** * Obtain a native SQL result set mapping defined via the annotation * {@link jakarta.persistence.SqlResultSetMapping}. diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/mutiny/impl/MutinyStatelessSessionImpl.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/mutiny/impl/MutinyStatelessSessionImpl.java index b7dc5c26c..275cd1cef 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/mutiny/impl/MutinyStatelessSessionImpl.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/mutiny/impl/MutinyStatelessSessionImpl.java @@ -193,6 +193,11 @@ public Uni fetch(T association) { return uni( () -> delegate.reactiveFetch( association, false ) ); } + @Override + public Object getIdentifier(Object entity) { + return delegate.getIdentifier(entity); + } + // @Override // public ResultSetMapping getResultSetMapping(Class resultType, String mappingName) { // return delegate.getResultSetMapping( resultType, mappingName ); diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/ReactiveStatelessSession.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/ReactiveStatelessSession.java index bed4725c5..a0b1f81f0 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/ReactiveStatelessSession.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/ReactiveStatelessSession.java @@ -71,4 +71,6 @@ public interface ReactiveStatelessSession extends ReactiveQueryProducer, Reactiv boolean isOpen(); void close(CompletableFuture closing); + + Object getIdentifier(Object entity); } diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/stage/Stage.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/stage/Stage.java index 44c34325c..f84034da5 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/stage/Stage.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/stage/Stage.java @@ -1916,6 +1916,17 @@ default CompletionStage refresh(Object entity, LockModeType lockModeType) */ CompletionStage fetch(T association); + /** + * Return the identifier value of the given entity, which may be detached. + * + * @param entity a persistent instance associated with this session + * + * @return the identifier + * + * @since 3.0 + */ + Object getIdentifier(Object entity); + /** * Obtain a native SQL result set mapping defined via the annotation * {@link jakarta.persistence.SqlResultSetMapping}. diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/stage/impl/StageStatelessSessionImpl.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/stage/impl/StageStatelessSessionImpl.java index 1bacfa354..48e7d8e9a 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/stage/impl/StageStatelessSessionImpl.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/stage/impl/StageStatelessSessionImpl.java @@ -132,6 +132,11 @@ public CompletionStage fetch(T association) { return delegate.reactiveFetch( association, false ); } + @Override + public Object getIdentifier(Object entity) { + return delegate.getIdentifier(entity); + } + @Override public CompletionStage withTransaction(Function> work) { return currentTransaction == null