Skip to content

Commit

Permalink
HHH-18753 SessionFactory.createEntityManager() should return Session
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin King <[email protected]>
  • Loading branch information
gavinking committed Oct 22, 2024
1 parent b1135b5 commit 2fc907c
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions hibernate-core/src/main/java/org/hibernate/SessionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
import java.io.Serializable;
import java.sql.Connection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
import javax.naming.Referenceable;

import jakarta.persistence.EntityManager;
import jakarta.persistence.SynchronizationType;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.engine.spi.FilterDefinition;
import org.hibernate.graph.RootGraph;
Expand Down Expand Up @@ -157,6 +160,8 @@ public interface SessionFactory extends EntityManagerFactory, Referenceable, Ser
*
* @return The created session.
*
* @apiNote This operation is very similar to {@link #createEntityManager()}
*
* @throws HibernateException Indicates a problem opening the session; pretty rare here.
*/
Session openSession() throws HibernateException;
Expand Down Expand Up @@ -294,6 +299,42 @@ default <R> R fromStatelessTransaction(Function<StatelessSession,R> action) {
return fromStatelessSession( session -> manageTransaction( session, session.beginTransaction(), action ) );
}

/**
* Create a new {@link Session}.
*/
@Override
Session createEntityManager();

/**
* Create a new {@link Session}, with the given
* {@linkplain EntityManager#getProperties properties}.
*/
@Override
Session createEntityManager(Map<?, ?> map);

/**
* Create a new {@link Session}, with the given
* {@linkplain SynchronizationType synchronization type}.
*
* @throws IllegalStateException if the persistence unit has
* {@linkplain jakarta.persistence.PersistenceUnitTransactionType#RESOURCE_LOCAL
* resource-local} transaction management
*/
@Override
Session createEntityManager(SynchronizationType synchronizationType);

/**
* Create a new {@link Session}, with the given
* {@linkplain SynchronizationType synchronization type} and
* {@linkplain EntityManager#getProperties properties}.
*
* @throws IllegalStateException if the persistence unit has
* {@linkplain jakarta.persistence.PersistenceUnitTransactionType#RESOURCE_LOCAL
* resource-local} transaction management
*/
@Override
Session createEntityManager(SynchronizationType synchronizationType, Map<?, ?> map);

/**
* Retrieve the {@linkplain Statistics statistics} for this factory.
*
Expand Down

0 comments on commit 2fc907c

Please sign in to comment.