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

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

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

SessionFactoryImplementor.withOptions介绍

暂无

代码示例

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

@Override
public SessionBuilderImplementor withOptions() {
  return delegate.withOptions();
}

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

protected SessionBuilder baseSessionBuilder() {
  final SessionBuilder builder = factory.withOptions();
  final CurrentTenantIdentifierResolver resolver = factory.getCurrentTenantIdentifierResolver();
  if ( resolver != null ) {
    builder.tenantIdentifier( resolver.resolveCurrentTenantIdentifier() );
  }
  return builder;
}

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

protected SessionBuilder newSession(String tenant) {
  return sessionFactory
    .withOptions()
    .tenantIdentifier( tenant );
}

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

protected Session openSession(Interceptor interceptor) throws HibernateException {
  session = sessionFactory().withOptions().interceptor( interceptor ).openSession();
  return session;
}

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

protected Session openSession(Interceptor interceptor) throws HibernateException {
  session = sessionFactory().withOptions().interceptor( interceptor ).openSession();
  return session;
}

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

@Override
protected SessionBuilder newSession(String tenant) {
  currentTenantResolver.currentTenantIdentifier = tenant;
  SessionBuilder sessionBuilder = sessionFactory.withOptions();
  try(Session session = sessionBuilder.openSession()) {
    Assert.assertEquals( tenant, session.getTenantIdentifier() );
  }
  return sessionBuilder;
}

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

@Override
protected Session getSessionUnderTest() throws Throwable {
  connectionUnderTest = cp.getConnection();
  Session session = sessionFactory().withOptions().connection( connectionUnderTest ).openSession();
  session.beginTransaction();
  return session;
}

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

@Test
@RequiresDialect(value = H2Dialect.class, comment = "this is more like a unit test")
public void testUserProvidedConnection() throws Exception {
  ConnectionProvider dcp = ConnectionProviderBuilder.buildConnectionProvider();
  Session s = sessionFactory().withOptions().connection( dcp.getConnection() ).openSession();
  Transaction tx = s.beginTransaction();
  s.createQuery( "from Fo" ).list();
  tx.commit();
  Connection c = s.disconnect();
  assertTrue( c != null );
  s.reconnect( c );
  tx = s.beginTransaction();
  s.createQuery( "from Fo" ).list();
  tx.commit();
  c.close();
}

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

return sessionFactory().withOptions().jdbcTimeZone( TIME_ZONE );
}, s -> {
  Person person = new Person();
  return sessionFactory().withOptions().jdbcTimeZone( TIME_ZONE );
}, s -> {
  s.doWork( connection -> {

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

@Test
@TestForIssue( jiraKey = "HHH-11396" )
public void testTimeZone() {
  TimeZone old = TimeZone.getDefault();
  try {
    // The producer (MySQL) Berlin and returns 1980-01-01
    TimeZone jdbcTimeZone = TimeZone.getTimeZone( "Europe/Berlin" );
    TimeZone.setDefault( jdbcTimeZone );
    //hibernate.connection.url jdbc:mysql://localhost/hibernate_orm_test
    doInHibernateSessionBuilder( () -> sessionFactory().withOptions().jdbcTimeZone( TIME_ZONE ), s -> {
      Person person = new Person();
      person.id = 1L;
      s.persist( person );
    } );
    doInHibernateSessionBuilder( () -> sessionFactory().withOptions().jdbcTimeZone( TIME_ZONE ), s -> {
      Person person = s.find( Person.class, 1L );
      assertEquals( LocalDate.of( 2017, 3, 7 ), person.createdOn );
    } );
  }
  finally {
    TimeZone.setDefault( old );
  }
}

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

@Test
public void testEntityTuplizer() throws Exception {
  //tag::entity-tuplizer-dynamic-proxy-example[]
  Cuisine _cuisine = doInHibernateSessionBuilder(
      () -> sessionFactory()
          .withOptions()
          .interceptor( new EntityNameInterceptor() ),
      session -> {
    Cuisine cuisine = ProxyHelper.newProxy( Cuisine.class, null );
    cuisine.setName( "Française" );
    Country country = ProxyHelper.newProxy( Country.class, null );
    country.setName( "France" );
    cuisine.setCountry( country );
    session.persist( cuisine );
    return cuisine;
  } );
  doInHibernateSessionBuilder(
      () -> sessionFactory()
          .withOptions()
          .interceptor( new EntityNameInterceptor() ),
      session -> {
    Cuisine cuisine = session.get( Cuisine.class, _cuisine.getId() );
    assertEquals( "Française", cuisine.getName() );
    assertEquals( "France", cuisine.getCountry().getName() );
  } );
  //end::entity-tuplizer-dynamic-proxy-example[]
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

protected SessionBuilder baseSessionBuilder() {
  final SessionBuilder builder = factory.withOptions();
  final CurrentTenantIdentifierResolver resolver = factory.getCurrentTenantIdentifierResolver();
  if ( resolver != null ) {
    builder.tenantIdentifier( resolver.resolveCurrentTenantIdentifier() );
  }
  return builder;
}

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

protected SessionBuilder baseSessionBuilder() {
  final SessionBuilder builder = factory.withOptions();
  final CurrentTenantIdentifierResolver resolver = factory.getCurrentTenantIdentifierResolver();
  if ( resolver != null ) {
    builder.tenantIdentifier( resolver.resolveCurrentTenantIdentifier() );
  }
  return builder;
}

代码示例来源:origin: com.atlassian.hibernate/hibernate.adapter

@Override
public Session openSession(final Connection connection) {
  final org.hibernate.Session sessionV5 = getSessionFactoryV5().withOptions().connection(connection).openSession();
  setupV5Session(sessionV5);
  return sessionAdapter.apply(sessionV5);
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

protected SessionBuilder baseSessionBuilder() {
  final SessionBuilder builder = factory.withOptions();
  final CurrentTenantIdentifierResolver resolver = factory.getCurrentTenantIdentifierResolver();
  if ( resolver != null ) {
    builder.tenantIdentifier( resolver.resolveCurrentTenantIdentifier() );
  }
  return builder;
}

代码示例来源:origin: com.atlassian.hibernate/hibernate.adapter

@Override
public Session openSession(final Connection connection, final Interceptor interceptor) {
  final org.hibernate.Session sessionV5 = getSessionFactoryV5().withOptions().connection(connection).interceptor(InterceptorV5Adapter.adapt(interceptor)).openSession();
  setupV5Session(sessionV5);
  return sessionAdapter.apply(sessionV5);
}

代码示例来源:origin: com.atlassian.hibernate/hibernate.adapter

@Override
public Session openSession(final Interceptor interceptor) throws HibernateException {
  try {
    final org.hibernate.Session sessionV5 = getSessionFactoryV5().withOptions().interceptor(InterceptorV5Adapter.adapt(interceptor)).openSession();
    setupV5Session(sessionV5);
    return sessionAdapter.apply(sessionV5);
  } catch (final PersistenceException ex) {
    throw HibernateExceptionAdapter.adapt(ex);
  }
}

代码示例来源:origin: com.atlassian.hibernate/hibernate.adapter

private org.hibernate.Session openV5Session(
    final SessionBridge sessionBridge,
    final Connection connection,
    final net.sf.hibernate.Interceptor interceptor) {
  return
      sessionFactoryBridge.getSessionFactoryV5().withOptions()
          .interceptor(InterceptorV5WithSessionBridgeHolder.create(sessionBridge, interceptor))
          .connection(connection)
          .openSession();
}

代码示例来源:origin: com.atlassian.hibernate/hibernate.adapter

private org.hibernate.Session openV5Session(
    final SessionBridge sessionBridge,
    final Connection connection) {
  final net.sf.hibernate.Interceptor defaultInterceptor =
      SessionFactoryImplV2Reflection.getInterceptor((net.sf.hibernate.impl.SessionFactoryImpl) sessionFactoryBridge.getSessionFactoryV2());
  return
      sessionFactoryBridge.getSessionFactoryV5().withOptions()
          .interceptor(InterceptorV5WithSessionBridgeHolder.create(sessionBridge, defaultInterceptor))
          .connection(connection)
          .openSession();
}

代码示例来源:origin: org.infinispan/infinispan-hibernate-cache-commons

protected <T> T withTxSessionApply(TxUtil.ThrowingFunction<Session, T, Exception> function) throws Exception {
  JtaPlatform jtaPlatform = useJta ? sessionFactory().getServiceRegistry().getService(JtaPlatform.class) : null;
  return TxUtil.withTxSessionApply(jtaPlatform, sessionFactory().withOptions(), function);
}

相关文章

微信公众号

最新文章

更多

SessionFactoryImplementor类方法