|
8 | 8 | import jakarta.persistence.PersistenceException; |
9 | 9 | import jakarta.transaction.SystemException; |
10 | 10 | import org.hibernate.AssertionFailure; |
11 | | -import org.hibernate.CacheMode; |
12 | 11 | import org.hibernate.FlushMode; |
13 | 12 | import org.hibernate.HibernateException; |
14 | | -import org.hibernate.Interceptor; |
15 | 13 | import org.hibernate.LockMode; |
16 | 14 | import org.hibernate.LockOptions; |
17 | | -import org.hibernate.SessionEventListener; |
18 | 15 | import org.hibernate.SessionException; |
19 | 16 | import org.hibernate.StatelessSession; |
20 | 17 | import org.hibernate.TransientObjectException; |
|
68 | 65 | import org.hibernate.loader.internal.CacheLoadHelper; |
69 | 66 | import org.hibernate.persister.collection.CollectionPersister; |
70 | 67 | import org.hibernate.persister.entity.EntityPersister; |
71 | | -import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode; |
72 | | -import org.hibernate.resource.jdbc.spi.StatementInspector; |
73 | 68 | import org.hibernate.stat.spi.StatisticsImplementor; |
74 | 69 |
|
75 | | -import java.sql.Connection; |
76 | 70 | import java.util.List; |
77 | 71 | import java.util.Set; |
78 | | -import java.util.TimeZone; |
79 | 72 | import java.util.function.BiConsumer; |
80 | 73 |
|
81 | 74 | import static org.hibernate.engine.internal.ManagedTypeHelper.asPersistentAttributeInterceptable; |
@@ -148,7 +141,7 @@ public StatelessSessionImpl(SessionFactoryImpl factory, SessionCreationOptions o |
148 | 141 | public StatelessSessionImpl(SessionFactoryImplementor factory, CommonSharedSessionCreationOptions options) { |
149 | 142 | super( |
150 | 143 | (SessionFactoryImpl) factory, |
151 | | - CommonSharedSessionCreationOptionsWrapper.wrapOptions( (SessionFactoryImpl) factory, options ) |
| 144 | + new SessionCreationOptionsAdaptor( factory, options ) |
152 | 145 | ); |
153 | 146 | connectionProvided = false; |
154 | 147 | transactionCompletionCallbacks = new TransactionCompletionCallbacksImpl( this ); |
@@ -1514,109 +1507,4 @@ public Integer getBatchSize() { |
1514 | 1507 | } |
1515 | 1508 | } |
1516 | 1509 |
|
1517 | | - /** |
1518 | | - * Wraps a CommonSharedSessionCreationOptions as a SessionCreationOptions to pass |
1519 | | - * to AbstractSharedSessionContract during construction. |
1520 | | - * |
1521 | | - * @param factory The SessionFactory |
1522 | | - * @param options The CommonSharedSessionCreationOptions being wrapped. |
1523 | | - */ |
1524 | | - private record CommonSharedSessionCreationOptionsWrapper( |
1525 | | - SessionFactoryImplementor factory, |
1526 | | - CommonSharedSessionCreationOptions options) |
1527 | | - implements SessionCreationOptions { |
1528 | | - |
1529 | | - private static SessionCreationOptions wrapOptions(SessionFactoryImpl factory, CommonSharedSessionCreationOptions options) { |
1530 | | - return new CommonSharedSessionCreationOptionsWrapper( factory, options ); |
1531 | | - } |
1532 | | - |
1533 | | - @Override |
1534 | | - public Interceptor getInterceptor() { |
1535 | | - return options.getInterceptor(); |
1536 | | - } |
1537 | | - |
1538 | | - @Override |
1539 | | - public StatementInspector getStatementInspector() { |
1540 | | - return options.getStatementInspector(); |
1541 | | - } |
1542 | | - |
1543 | | - @Override |
1544 | | - public Object getTenantIdentifierValue() { |
1545 | | - return options.getTenantIdentifierValue(); |
1546 | | - } |
1547 | | - |
1548 | | - @Override |
1549 | | - public boolean isReadOnly() { |
1550 | | - return options.isReadOnly(); |
1551 | | - } |
1552 | | - |
1553 | | - @Override |
1554 | | - public CacheMode getInitialCacheMode() { |
1555 | | - return options.getInitialCacheMode(); |
1556 | | - } |
1557 | | - |
1558 | | - @Override |
1559 | | - public boolean shouldAutoJoinTransactions() { |
1560 | | - return true; |
1561 | | - } |
1562 | | - |
1563 | | - @Override |
1564 | | - public FlushMode getInitialSessionFlushMode() { |
1565 | | - return FlushMode.ALWAYS; |
1566 | | - } |
1567 | | - |
1568 | | - @Override |
1569 | | - public boolean isSubselectFetchEnabled() { |
1570 | | - return false; |
1571 | | - } |
1572 | | - |
1573 | | - @Override |
1574 | | - public int getDefaultBatchFetchSize() { |
1575 | | - return -1; |
1576 | | - } |
1577 | | - |
1578 | | - @Override |
1579 | | - public boolean shouldAutoClose() { |
1580 | | - return false; |
1581 | | - } |
1582 | | - |
1583 | | - @Override |
1584 | | - public boolean shouldAutoClear() { |
1585 | | - return false; |
1586 | | - } |
1587 | | - |
1588 | | - @Override |
1589 | | - public Connection getConnection() { |
1590 | | - return null; |
1591 | | - } |
1592 | | - |
1593 | | - @Override |
1594 | | - public boolean isIdentifierRollbackEnabled() { |
1595 | | - // identifier rollback not yet implemented for StatelessSessions |
1596 | | - return false; |
1597 | | - } |
1598 | | - |
1599 | | - @Override |
1600 | | - public PhysicalConnectionHandlingMode getPhysicalConnectionHandlingMode() { |
1601 | | - return factory.getSessionFactoryOptions().getPhysicalConnectionHandlingMode(); |
1602 | | - } |
1603 | | - |
1604 | | - @Override |
1605 | | - public String getTenantIdentifier() { |
1606 | | - final Object tenantIdentifier = getTenantIdentifierValue(); |
1607 | | - return tenantIdentifier == null |
1608 | | - ? null |
1609 | | - : factory.getTenantIdentifierJavaType().toString( tenantIdentifier ); |
1610 | | - } |
1611 | | - |
1612 | | - @Override |
1613 | | - public TimeZone getJdbcTimeZone() { |
1614 | | - return factory.getSessionFactoryOptions().getJdbcTimeZone(); |
1615 | | - } |
1616 | | - |
1617 | | - @Override |
1618 | | - public List<SessionEventListener> getCustomSessionEventListener() { |
1619 | | - return null; |
1620 | | - } |
1621 | | - } |
1622 | 1510 | } |
0 commit comments