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
16 changes: 8 additions & 8 deletions hibernate-core/src/main/java/org/hibernate/SessionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public interface SessionFactory extends EntityManagerFactory, Referenceable, Ser
/**
* Open a {@link Session} and use it to perform an action.
*/
default void inSession(Consumer<Session> action) {
default void inSession(Consumer<? super Session> action) {
try ( Session session = openSession() ) {
action.accept( session );
}
Expand All @@ -231,7 +231,7 @@ default void inSession(Consumer<Session> action) {
*
* @since 6.3
*/
default void inStatelessSession(Consumer<StatelessSession> action) {
default void inStatelessSession(Consumer<? super StatelessSession> action) {
try ( StatelessSession session = openStatelessSession() ) {
action.accept( session );
}
Expand All @@ -244,7 +244,7 @@ default void inStatelessSession(Consumer<StatelessSession> action) {
* @apiNote This method competes with the JPA-defined method
* {@link #runInTransaction}
*/
default void inTransaction(Consumer<Session> action) {
default void inTransaction(Consumer<? super Session> action) {
inSession( session -> manageTransaction( session, session.beginTransaction(), action ) );
}

Expand All @@ -254,14 +254,14 @@ default void inTransaction(Consumer<Session> action) {
*
* @since 6.3
*/
default void inStatelessTransaction(Consumer<StatelessSession> action) {
default void inStatelessTransaction(Consumer<? super StatelessSession> action) {
inStatelessSession( session -> manageTransaction( session, session.beginTransaction(), action ) );
}

/**
* Open a {@link Session} and use it to obtain a value.
*/
default <R> R fromSession(Function<Session,R> action) {
default <R> R fromSession(Function<? super Session,R> action) {
try ( Session session = openSession() ) {
return action.apply( session );
}
Expand All @@ -272,7 +272,7 @@ default <R> R fromSession(Function<Session,R> action) {
*
* @since 6.3
*/
default <R> R fromStatelessSession(Function<StatelessSession,R> action) {
default <R> R fromStatelessSession(Function<? super StatelessSession,R> action) {
try ( StatelessSession session = openStatelessSession() ) {
return action.apply( session );
}
Expand All @@ -285,7 +285,7 @@ default <R> R fromStatelessSession(Function<StatelessSession,R> action) {
* @apiNote This method competes with the JPA-defined method
* {@link #callInTransaction}
*/
default <R> R fromTransaction(Function<Session,R> action) {
default <R> R fromTransaction(Function<? super Session,R> action) {
return fromSession( session -> manageTransaction( session, session.beginTransaction(), action ) );
}

Expand All @@ -295,7 +295,7 @@ default <R> R fromTransaction(Function<Session,R> action) {
*
* @since 6.3
*/
default <R> R fromStatelessTransaction(Function<StatelessSession,R> action) {
default <R> R fromStatelessTransaction(Function<? super StatelessSession,R> action) {
return fromStatelessSession( session -> manageTransaction( session, session.beginTransaction(), action ) );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,11 @@ public interface JdbcSettings extends C3p0Settings, ProxoolSettings, AgroalSetti

/**
* Controls the autocommit mode of JDBC connections obtained from any
* {@link ConnectionProvider} implementation
* which respects this setting, which the built-in implementations do, except for
* {@link ConnectionProvider} implementation which respects this setting,
* which includes the built-in implementations do, except for
* {@link org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl}.
*
* @settingDefault {@code false}
*/
String AUTOCOMMIT = "hibernate.connection.autocommit";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -904,15 +904,14 @@ public <E> Map<String, EntityGraph<? extends E>> getNamedEntityGraphs(Class<E> e
return getJpaMetamodel().getNamedEntityGraphs( entityType );
}

@Override @SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void runInTransaction(Consumer<EntityManager> work) {
inTransaction( (Consumer) work );
inTransaction( work );
}

@Override
public <R> R callInTransaction(Function<EntityManager, R> work) {
//noinspection unchecked,rawtypes
return (R) fromTransaction( (Function) work );
return fromTransaction( work );
}

@Override
Expand Down
Loading