Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ default void inStatelessSession(Consumer<StatelessSession> action) {
/**
* 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<Session> action) {
inSession( session -> manageTransaction( session, session.beginTransaction(), action ) );
Expand Down Expand Up @@ -273,6 +276,9 @@ default <R> R fromStatelessSession(Function<StatelessSession,R> action) {
/**
* 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> R fromTransaction(Function<Session,R> action) {
return fromSession( session -> manageTransaction( session, session.beginTransaction(), action ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
*/
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();

Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -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()
*/
Expand Down Expand Up @@ -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,
Expand All @@ -243,10 +253,11 @@ default void doWork(Work work) throws HibernateException {
* @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> T doReturningWork(ReturningWork<T> work) throws HibernateException {
throw new UnsupportedOperationException();
}
<T> T doReturningWork(ReturningWork<T> work);

/**
* Create a new mutable {@link EntityGraph} with only a root node.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
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;
Expand Down
Loading