org.hibernate.engine.spi.SessionFactoryImplementor.getCurrentSession()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(74)

本文整理了Java中org.hibernate.engine.spi.SessionFactoryImplementor.getCurrentSession()方法的一些代码示例,展示了SessionFactoryImplementor.getCurrentSession()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SessionFactoryImplementor.getCurrentSession()方法的具体详情如下:
包路径:org.hibernate.engine.spi.SessionFactoryImplementor
类名称:SessionFactoryImplementor
方法名:getCurrentSession

SessionFactoryImplementor.getCurrentSession介绍

暂无

代码示例

代码示例来源:origin: hibernate/hibernate-orm

@Override
public Session getCurrentSession() throws HibernateException {
  return delegate.getCurrentSession();
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
protected Session getSessionUnderTest() throws Throwable {
  Session session = sessionFactory().getCurrentSession();
  session.beginTransaction();
  return session;
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
protected Session getSessionUnderTest() throws Throwable {
  return sessionFactory().getCurrentSession();
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testTransactionProtection() {
  Session session = sessionFactory().getCurrentSession();
  try {
    session.createQuery( "from Silly" );
    fail( "method other than beginTransaction() allowed" );
  }
  catch ( HibernateException e ) {
    // ok
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
@TestForIssue(jiraKey = "HHH-11067")
public void testEqualityChecking() {
  Session session1 = sessionFactory().getCurrentSession();
  Session session2 = sessionFactory().getCurrentSession();
  assertSame( "== check", session1, session2 );
  assertEquals( "#equals check", session1, session2 );
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testCurrentSession() throws Exception {
  TestingJtaPlatformImpl.INSTANCE.getTransactionManager().begin();
  Session s = sessionFactory().getCurrentSession();
  Session s2 = sessionFactory().getCurrentSession();
  assertSame( s, s2 );
  TestingJtaPlatformImpl.INSTANCE.getTransactionManager().commit();
  assertFalse( s.isOpen() );
  // TODO : would be nice to automate-test that the SF internal map actually gets cleaned up
  //      i verified that is does currently in my debugger...
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testContextCleanup() {
  Session session = sessionFactory().getCurrentSession();
  session.beginTransaction();
  session.getTransaction().commit();
  assertFalse( "session open after txn completion", session.isOpen() );
  assertFalse( "session still bound after txn completion", TestableThreadLocalContext.isSessionBound( session ) );
  Session session2 = sessionFactory().getCurrentSession();
  assertFalse( "same session returned after txn completion", session == session2 );
  session2.close();
  assertFalse( "session open after closing", session2.isOpen() );
  assertFalse( "session still bound after closing", TestableThreadLocalContext.isSessionBound( session2 ) );
}

代码示例来源:origin: hibernate/hibernate-orm

s = sessionFactory().getCurrentSession();
Iterator itr = s.createQuery( "from Item" ).iterate();
if ( !itr.hasNext() ) {
s = sessionFactory().getCurrentSession();
itr = s.createQuery( "from Item" ).iterate();
if ( !itr.hasNext() ) {

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testCurrentSessionWithScroll() throws Exception {
  TestingJtaPlatformImpl.INSTANCE.getTransactionManager().begin();
  Session s = sessionFactory().getCurrentSession();
  Map item1 = new HashMap();
  item1.put( "name", "Item - 1" );
  s = sessionFactory().getCurrentSession();
  ScrollableResults results = s.createQuery( "from Item" ).scroll();
  results.next();
  s = sessionFactory().getCurrentSession();
  results = s.createQuery( "from Item" ).scroll();
  results.next();
  s = sessionFactory().getCurrentSession();
  results = s.createQuery( "from Item" ).scroll();
  while ( results.next() ) {
  s = sessionFactory().getCurrentSession();
  results = s.createQuery( "from Item" ).scroll();
  while ( results.next() ) {
  s = sessionFactory().getCurrentSession();
  s.createQuery( "delete from Item" ).executeUpdate();
  TestingJtaPlatformImpl.INSTANCE.getTransactionManager().commit();

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testLobCreation() throws SQLException {
  Session session = sessionFactory().getCurrentSession();
  session.beginTransaction();
  Blob blob = Hibernate.getLobCreator( session ).createBlob( new byte[] {} );
  blob.free();
  Clob clob = Hibernate.getLobCreator( session ).createClob( "Steve" );
  clob.free();
  session.getTransaction().commit();
  assertFalse( session.isOpen() );
}

代码示例来源:origin: org.hibernate.orm/hibernate-core

@Override
public Session getCurrentSession() throws HibernateException {
  return delegate.getCurrentSession();
}

代码示例来源:origin: stackoverflow.com

FlushEntityEventListener.onFlushEntity(FlushEntityEvent event)
EntityEvent entityEvent = event.getEntityEntry();
EntityPersister persister = entityEvent.getPersister();
SessionFactoryImplementor sessionFactoryImplor = persister.getFactory();
Session session = sessionFactoryImplor.getCurrentSession();

代码示例来源:origin: hibernate/hibernate-ogm

@Override
public OgmSession getCurrentSession() throws HibernateException {
  final Session session = delegate().getCurrentSession();
  return new OgmSessionImpl( this, (EventSource) session );
}

代码示例来源:origin: com.github.albfernandez/jbpm-jpdl

public void execute() throws BuildException {
 JbpmHibernateConfiguration jbpmHibernateConfiguration = AntHelper.getConfiguration(config, properties);
 SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) jbpmHibernateConfiguration.buildSessionFactory();
 try ( Session session = sessionFactory.getCurrentSession()) {
  session.doWork( new Work()
  {
   @Override
   public void execute( Connection connection ) throws SQLException {
    try (Statement statement = connection.createStatement()) {
      log( "shutting down database" );
      statement.executeUpdate( "SHUTDOWN" );
      statement.close();
    }
    catch ( SQLException e ) {
      throw new BuildException( "could not shut down database", e );
    }
    finally {
     try{
      if ( connection != null ) {
       connection.close();
      }
     }
     catch ( SQLException e ) {
       // ignore
     }
    }
   }
  } );
 }
}

相关文章

微信公众号

最新文章

更多

SessionFactoryImplementor类方法