expand Javadoc of CURRENT_SESSION_CONTEXT_CLASS
This commit is contained in:
parent
06e44f2adb
commit
7b0270cc74
|
@ -1015,7 +1015,13 @@ public interface AvailableSettings {
|
|||
/**
|
||||
* Specifies a {@link org.hibernate.context.spi.CurrentSessionContext} for
|
||||
* scoping the {@linkplain org.hibernate.SessionFactory#getCurrentSession()
|
||||
* current session}.
|
||||
* current session}, either:<ul>
|
||||
* <li>{@code jta}, {@code thread}, or {@code managed}, or
|
||||
* <li>the name of a class implementing
|
||||
* {@code org.hibernate.context.spi.CurrentSessionContext}.
|
||||
* </ul>
|
||||
*
|
||||
* @see org.hibernate.SessionFactory#getCurrentSession()
|
||||
*/
|
||||
String CURRENT_SESSION_CONTEXT_CLASS = "hibernate.current_session_context_class";
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
package org.hibernate.orm.test.stateless;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
|
||||
|
@ -14,9 +16,12 @@ import org.hibernate.ScrollMode;
|
|||
import org.hibernate.ScrollableResults;
|
||||
import org.hibernate.Transaction;
|
||||
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.Setting;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -31,6 +36,9 @@ import static org.junit.jupiter.api.Assertions.assertNotSame;
|
|||
xmlMappings = "org/hibernate/orm/test/stateless/Document.hbm.xml"
|
||||
)
|
||||
@SessionFactory
|
||||
@ServiceRegistry(
|
||||
settings = @Setting(name = Environment.STATEMENT_BATCH_SIZE, value = "4")
|
||||
)
|
||||
public class StatelessSessionTest {
|
||||
|
||||
@AfterEach
|
||||
|
@ -41,6 +49,42 @@ public class StatelessSessionTest {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateBatch(SessionFactoryScope scope) {
|
||||
scope.inStatelessSession(
|
||||
statelessSession -> {
|
||||
try {
|
||||
Transaction tx = statelessSession.beginTransaction();
|
||||
Document doc1 = new Document( "blah", "Blahs1" );
|
||||
statelessSession.insert( doc1 );
|
||||
assertNotNull( doc1.getName() );
|
||||
|
||||
System.out.println("blah");
|
||||
Document doc2 = new Document( "blah blah", "Blahs2" );
|
||||
statelessSession.insert( doc2 );
|
||||
assertNotNull( doc2.getName() );
|
||||
System.out.println("blah blah");
|
||||
|
||||
Document doc3 = new Document( "blah blah blah", "Blahs3" );
|
||||
statelessSession.insert( doc3 );
|
||||
assertNotNull( doc3.getName() );
|
||||
System.out.println("blah blah blah");
|
||||
Date initVersion = doc1.getLastModified();
|
||||
assertNotNull( initVersion );
|
||||
tx.commit();
|
||||
|
||||
List documents = statelessSession.createQuery("from Document").getResultList();
|
||||
assertEquals( 3, documents.size() );
|
||||
}
|
||||
catch (Exception e) {
|
||||
if ( statelessSession.getTransaction().isActive() ) {
|
||||
statelessSession.getTransaction().rollback();
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
} );
|
||||
}
|
||||
@Test
|
||||
public void testCreateUpdateReadDelete(SessionFactoryScope scope) {
|
||||
scope.inStatelessSession(
|
||||
|
|
Loading…
Reference in New Issue