diff --git a/hibernate-core/src/main/java/org/hibernate/SessionFactory.java b/hibernate-core/src/main/java/org/hibernate/SessionFactory.java index 6ae33f1a94..27ad1fe326 100644 --- a/hibernate-core/src/main/java/org/hibernate/SessionFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/SessionFactory.java @@ -235,6 +235,9 @@ public interface SessionFactory extends EntityManagerFactory, Referenceable, Ser /** * Open a {@link Session} and use it to perform an action * within the bounds of a transaction. + * + * @apiNote This method competes with the JPA-defined method + * {@link #runInTransaction} */ default void inTransaction(Consumer action) { inSession( session -> manageTransaction( session, session.beginTransaction(), action ) ); @@ -273,6 +276,9 @@ public interface SessionFactory extends EntityManagerFactory, Referenceable, Ser /** * Open a {@link Session} and use it to obtain a value * within the bounds of a transaction. + * + * @apiNote This method competes with the JPA-defined method + * {@link #callInTransaction} */ default R fromTransaction(Function action) { return fromSession( session -> manageTransaction( session, session.beginTransaction(), action ) ); diff --git a/hibernate-core/src/main/java/org/hibernate/SharedSessionContract.java b/hibernate-core/src/main/java/org/hibernate/SharedSessionContract.java index e0ed2eb532..c945057f00 100644 --- a/hibernate-core/src/main/java/org/hibernate/SharedSessionContract.java +++ b/hibernate-core/src/main/java/org/hibernate/SharedSessionContract.java @@ -22,9 +22,12 @@ import org.hibernate.query.criteria.HibernateCriteriaBuilder; */ public interface SharedSessionContract extends QueryProducer, AutoCloseable, Serializable { /** - * Obtain the tenant identifier associated with this session. + * Obtain the tenant identifier associated with this session, as a string. * * @return The tenant identifier associated with this session, or {@code null} + * + * @see org.hibernate.context.spi.CurrentTenantIdentifierResolver + * @see SessionBuilder#tenantIdentifier(Object) */ String getTenantIdentifier(); @@ -33,6 +36,9 @@ public interface SharedSessionContract extends QueryProducer, AutoCloseable, Ser * * @return The tenant identifier associated with this session, or {@code null} * @since 6.4 + * + * @see org.hibernate.context.spi.CurrentTenantIdentifierResolver + * @see SessionBuilder#tenantIdentifier(Object) */ Object getTenantIdentifierValue(); @@ -41,19 +47,20 @@ public interface SharedSessionContract extends QueryProducer, AutoCloseable, Ser * * @throws HibernateException Indicates problems cleaning up. */ + @Override void close() throws HibernateException; /** * Check if the session is still open. * - * @return boolean + * @return {@code true} if it is open */ boolean isOpen(); /** * Check if the session is currently connected. * - * @return boolean + * @return {@code true} if it is connected */ boolean isConnected(); @@ -62,16 +69,18 @@ public interface SharedSessionContract extends QueryProducer, AutoCloseable, Ser * If a new underlying transaction is required, begin the transaction. Otherwise, * continue the new work in the context of the existing underlying transaction. * - * @return a {@link Transaction} instance + * @return an instance of {@link Transaction} representing the new transaction * * @see #getTransaction() + * @see Transaction#begin() */ Transaction beginTransaction(); /** * Get the {@link Transaction} instance associated with this session. * - * @return a Transaction instance + * @return an instance of {@link Transaction} representing the transaction + * associated with this session * * @see jakarta.persistence.EntityManager#getTransaction() */ @@ -228,10 +237,11 @@ public interface SharedSessionContract extends QueryProducer, AutoCloseable, Ser * @param work The work to be performed. * * @throws HibernateException Generally indicates wrapped {@link java.sql.SQLException} + * + * @apiNote This method competes with the JPA-defined method + * {@link jakarta.persistence.EntityManager#runWithConnection} */ - default void doWork(Work work) throws HibernateException { - throw new UnsupportedOperationException(); - } + void doWork(Work work) throws HibernateException; /** * Perform work using the {@link java.sql.Connection} underlying by this session, @@ -243,10 +253,11 @@ public interface SharedSessionContract extends QueryProducer, AutoCloseable, Ser * @return the result of calling {@link ReturningWork#execute}. * * @throws HibernateException Generally indicates wrapped {@link java.sql.SQLException} + * + * @apiNote This method competes with the JPA-defined method + * {@link jakarta.persistence.EntityManager#callWithConnection} */ - default T doReturningWork(ReturningWork work) throws HibernateException { - throw new UnsupportedOperationException(); - } + T doReturningWork(ReturningWork work); /** * Create a new mutable {@link EntityGraph} with only a root node. diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/InsertCoordinatorStandard.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/InsertCoordinatorStandard.java index 80ee294942..444e95a584 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/InsertCoordinatorStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/InsertCoordinatorStandard.java @@ -24,7 +24,6 @@ import org.hibernate.generator.Generator; import org.hibernate.generator.OnExecutionGenerator; import org.hibernate.generator.values.GeneratedValues; import org.hibernate.generator.values.GeneratedValuesMutationDelegate; -import org.hibernate.id.IdentifierGenerationException; import org.hibernate.metamodel.mapping.AttributeMapping; import org.hibernate.metamodel.mapping.AttributeMappingsList; import org.hibernate.metamodel.mapping.BasicEntityIdentifierMapping;