HHH-18753 SessionFactory.createEntityManager() should return Session
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
c39f0bc3b6
commit
37ce9bb31c
|
@ -7,11 +7,14 @@ package org.hibernate;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import javax.naming.Referenceable;
|
import javax.naming.Referenceable;
|
||||||
|
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.persistence.SynchronizationType;
|
||||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||||
import org.hibernate.engine.spi.FilterDefinition;
|
import org.hibernate.engine.spi.FilterDefinition;
|
||||||
import org.hibernate.graph.RootGraph;
|
import org.hibernate.graph.RootGraph;
|
||||||
|
@ -157,6 +160,8 @@ public interface SessionFactory extends EntityManagerFactory, Referenceable, Ser
|
||||||
*
|
*
|
||||||
* @return The created session.
|
* @return The created session.
|
||||||
*
|
*
|
||||||
|
* @apiNote This operation is very similar to {@link #createEntityManager()}
|
||||||
|
*
|
||||||
* @throws HibernateException Indicates a problem opening the session; pretty rare here.
|
* @throws HibernateException Indicates a problem opening the session; pretty rare here.
|
||||||
*/
|
*/
|
||||||
Session openSession() throws HibernateException;
|
Session openSession() throws HibernateException;
|
||||||
|
@ -294,6 +299,42 @@ public interface SessionFactory extends EntityManagerFactory, Referenceable, Ser
|
||||||
return fromStatelessSession( session -> manageTransaction( session, session.beginTransaction(), 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.
|
* Retrieve the {@linkplain Statistics statistics} for this factory.
|
||||||
*
|
*
|
||||||
|
|
|
@ -348,22 +348,22 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityManager createEntityManager() {
|
public Session createEntityManager() {
|
||||||
return delegate.createEntityManager();
|
return delegate.createEntityManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityManager createEntityManager(Map map) {
|
public Session createEntityManager(Map map) {
|
||||||
return delegate.createEntityManager( map );
|
return delegate.createEntityManager( map );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityManager createEntityManager(SynchronizationType synchronizationType) {
|
public Session createEntityManager(SynchronizationType synchronizationType) {
|
||||||
return delegate.createEntityManager( synchronizationType );
|
return delegate.createEntityManager( synchronizationType );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityManager createEntityManager(SynchronizationType synchronizationType, Map map) {
|
public Session createEntityManager(SynchronizationType synchronizationType, Map map) {
|
||||||
return delegate.createEntityManager( synchronizationType, map );
|
return delegate.createEntityManager( synchronizationType, map );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue