org.hibernate.SessionFactory.unwrap()方法的使用及代码示例

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

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

SessionFactory.unwrap介绍

暂无

代码示例

代码示例来源:origin: org.codehaus.griffon.plugins/griffon-hibernate5-core

@Override
public <T> T unwrap(Class<T> cls) {
  return delegate.unwrap(cls);
}

代码示例来源:origin: net.krotscheck/kangaroo-common

/**
 * Create a new pooled data source factory.
 *
 * @param sessionFactory The Hibernate Session Factory, Injected.
 */
@Inject
public PooledDataSourceFactory(final SessionFactory sessionFactory) {
  this.sessionFactory = sessionFactory.unwrap(SessionFactoryImpl.class);
}

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

@Test
public void shouldHandleTenantIds() throws Exception {
  long executionId = jobOperator.start(
      MassIndexingJob.NAME,
      MassIndexingJob.parameters()
          .forEntity( Company.class )
          .tenantId( TARGET_TENANT_ID )
          .build()
  );
  JobExecution jobExecution = jobOperator.getJobExecution( executionId );
  JobTestUtil.waitForTermination( jobOperator, jobExecution, JOB_TIMEOUT_MS );
  assertThat( jobExecution.getBatchStatus() ).isEqualTo( BatchStatus.COMPLETED );
  EntityManagerFactory emf = getSessionFactory().unwrap( EntityManagerFactory.class );
  assertThat( findIndexedResultsInTenant( emf, Company.class, "name", "Google", TARGET_TENANT_ID ) ).hasSize( 1 );
  assertThat( findIndexedResultsInTenant( emf, Company.class, "name", "Red Hat", TARGET_TENANT_ID ) ).hasSize( 1 );
  assertThat( findIndexedResultsInTenant( emf, Company.class, "name", "Microsoft", TARGET_TENANT_ID ) ).hasSize( 1 );
  assertThat( findIndexedResultsInTenant( emf, Company.class, "name", "Google", UNUSED_TENANT_ID ) ).isEmpty();
  assertThat( findIndexedResultsInTenant( emf, Company.class, "name", "Red Hat", UNUSED_TENANT_ID ) ).isEmpty();
  assertThat( findIndexedResultsInTenant( emf, Company.class, "name", "Microsoft", UNUSED_TENANT_ID ) ).isEmpty();
}

相关文章