Skip to content

Commit 1b00f69

Browse files
committed
remove two default impls that threw UnsupportedOperationException
added some links in Javadoc Signed-off-by: Gavin King <[email protected]>
1 parent 0f35a7d commit 1b00f69

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

hibernate-core/src/main/java/org/hibernate/SessionFactory.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,9 @@ default void inStatelessSession(Consumer<StatelessSession> action) {
235235
/**
236236
* Open a {@link Session} and use it to perform an action
237237
* within the bounds of a transaction.
238+
*
239+
* @apiNote This method competes with the JPA-defined method
240+
* {@link #runInTransaction}
238241
*/
239242
default void inTransaction(Consumer<Session> action) {
240243
inSession( session -> manageTransaction( session, session.beginTransaction(), action ) );
@@ -273,6 +276,9 @@ default <R> R fromStatelessSession(Function<StatelessSession,R> action) {
273276
/**
274277
* Open a {@link Session} and use it to obtain a value
275278
* within the bounds of a transaction.
279+
*
280+
* @apiNote This method competes with the JPA-defined method
281+
* {@link #callInTransaction}
276282
*/
277283
default <R> R fromTransaction(Function<Session,R> action) {
278284
return fromSession( session -> manageTransaction( session, session.beginTransaction(), action ) );

hibernate-core/src/main/java/org/hibernate/SharedSessionContract.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@
2222
*/
2323
public interface SharedSessionContract extends QueryProducer, AutoCloseable, Serializable {
2424
/**
25-
* Obtain the tenant identifier associated with this session.
25+
* Obtain the tenant identifier associated with this session, as a string.
2626
*
2727
* @return The tenant identifier associated with this session, or {@code null}
28+
*
29+
* @see org.hibernate.context.spi.CurrentTenantIdentifierResolver
30+
* @see SessionBuilder#tenantIdentifier(Object)
2831
*/
2932
String getTenantIdentifier();
3033

@@ -33,6 +36,9 @@ public interface SharedSessionContract extends QueryProducer, AutoCloseable, Ser
3336
*
3437
* @return The tenant identifier associated with this session, or {@code null}
3538
* @since 6.4
39+
*
40+
* @see org.hibernate.context.spi.CurrentTenantIdentifierResolver
41+
* @see SessionBuilder#tenantIdentifier(Object)
3642
*/
3743
Object getTenantIdentifierValue();
3844

@@ -41,19 +47,20 @@ public interface SharedSessionContract extends QueryProducer, AutoCloseable, Ser
4147
*
4248
* @throws HibernateException Indicates problems cleaning up.
4349
*/
50+
@Override
4451
void close() throws HibernateException;
4552

4653
/**
4754
* Check if the session is still open.
4855
*
49-
* @return boolean
56+
* @return {@code true} if it is open
5057
*/
5158
boolean isOpen();
5259

5360
/**
5461
* Check if the session is currently connected.
5562
*
56-
* @return boolean
63+
* @return {@code true} if it is connected
5764
*/
5865
boolean isConnected();
5966

@@ -62,16 +69,18 @@ public interface SharedSessionContract extends QueryProducer, AutoCloseable, Ser
6269
* If a new underlying transaction is required, begin the transaction. Otherwise,
6370
* continue the new work in the context of the existing underlying transaction.
6471
*
65-
* @return a {@link Transaction} instance
72+
* @return an instance of {@link Transaction} representing the new transaction
6673
*
6774
* @see #getTransaction()
75+
* @see Transaction#begin()
6876
*/
6977
Transaction beginTransaction();
7078

7179
/**
7280
* Get the {@link Transaction} instance associated with this session.
7381
*
74-
* @return a Transaction instance
82+
* @return an instance of {@link Transaction} representing the transaction
83+
* associated with this session
7584
*
7685
* @see jakarta.persistence.EntityManager#getTransaction()
7786
*/
@@ -228,10 +237,11 @@ public interface SharedSessionContract extends QueryProducer, AutoCloseable, Ser
228237
* @param work The work to be performed.
229238
*
230239
* @throws HibernateException Generally indicates wrapped {@link java.sql.SQLException}
240+
*
241+
* @apiNote This method competes with the JPA-defined method
242+
* {@link jakarta.persistence.EntityManager#runWithConnection}
231243
*/
232-
default void doWork(Work work) throws HibernateException {
233-
throw new UnsupportedOperationException();
234-
}
244+
void doWork(Work work) throws HibernateException;
235245

236246
/**
237247
* Perform work using the {@link java.sql.Connection} underlying by this session,
@@ -243,10 +253,11 @@ default void doWork(Work work) throws HibernateException {
243253
* @return the result of calling {@link ReturningWork#execute}.
244254
*
245255
* @throws HibernateException Generally indicates wrapped {@link java.sql.SQLException}
256+
*
257+
* @apiNote This method competes with the JPA-defined method
258+
* {@link jakarta.persistence.EntityManager#callWithConnection}
246259
*/
247-
default <T> T doReturningWork(ReturningWork<T> work) throws HibernateException {
248-
throw new UnsupportedOperationException();
249-
}
260+
<T> T doReturningWork(ReturningWork<T> work);
250261

251262
/**
252263
* Create a new mutable {@link EntityGraph} with only a root node.

hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/InsertCoordinatorStandard.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.hibernate.generator.OnExecutionGenerator;
2525
import org.hibernate.generator.values.GeneratedValues;
2626
import org.hibernate.generator.values.GeneratedValuesMutationDelegate;
27-
import org.hibernate.id.IdentifierGenerationException;
2827
import org.hibernate.metamodel.mapping.AttributeMapping;
2928
import org.hibernate.metamodel.mapping.AttributeMappingsList;
3029
import org.hibernate.metamodel.mapping.BasicEntityIdentifierMapping;

0 commit comments

Comments
 (0)