use of org.hibernate.mapping.PersistentClass in project hibernate-orm by hibernate.
the class SecondLevelCacheStressTestCase method buildMetadata.
private static Metadata buildMetadata(StandardServiceRegistry registry) {
final String cacheStrategy = "transactional";
MetadataSources metadataSources = new MetadataSources(registry);
for (Class entityClass : getAnnotatedClasses()) {
metadataSources.addAnnotatedClass(entityClass);
}
Metadata metadata = metadataSources.buildMetadata();
for (PersistentClass entityBinding : metadata.getEntityBindings()) {
if (!entityBinding.isInherited()) {
((RootClass) entityBinding).setCacheConcurrencyStrategy(cacheStrategy);
}
}
for (Collection collectionBinding : metadata.getCollectionBindings()) {
collectionBinding.setCacheConcurrencyStrategy(cacheStrategy);
}
return metadata;
}
use of org.hibernate.mapping.PersistentClass in project hibernate-orm by hibernate.
the class JBossStandaloneJtaExampleTest method buildSessionFactory.
private SessionFactory buildSessionFactory() {
// Extra options located in src/test/resources/hibernate.properties
StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder().applySetting(Environment.DIALECT, "HSQL").applySetting(Environment.HBM2DDL_AUTO, "create-drop").applySetting(Environment.CONNECTION_PROVIDER, JtaAwareConnectionProviderImpl.class.getName()).applySetting(Environment.JNDI_CLASS, "org.jnp.interfaces.NamingContextFactory").applySetting(Environment.TRANSACTION_COORDINATOR_STRATEGY, JtaTransactionCoordinatorBuilderImpl.class.getName()).applySetting(Environment.CURRENT_SESSION_CONTEXT_CLASS, "jta").applySetting(Environment.RELEASE_CONNECTIONS, "auto").applySetting(Environment.USE_SECOND_LEVEL_CACHE, "true").applySetting(Environment.USE_QUERY_CACHE, "true").applySetting(Environment.JTA_PLATFORM, new JBossStandAloneJtaPlatform()).applySetting(Environment.CACHE_REGION_FACTORY, TestInfinispanRegionFactory.class.getName());
StandardServiceRegistry serviceRegistry = ssrb.build();
MetadataSources metadataSources = new MetadataSources(serviceRegistry);
metadataSources.addResource("org/hibernate/test/cache/infinispan/functional/entities/Item.hbm.xml");
Metadata metadata = metadataSources.buildMetadata();
for (PersistentClass entityBinding : metadata.getEntityBindings()) {
if (entityBinding instanceof RootClass) {
((RootClass) entityBinding).setCacheConcurrencyStrategy("transactional");
}
}
for (Collection collectionBinding : metadata.getCollectionBindings()) {
collectionBinding.setCacheConcurrencyStrategy("transactional");
}
return metadata.buildSessionFactory();
}
use of org.hibernate.mapping.PersistentClass in project hibernate-orm by hibernate.
the class CollectionMetadataGenerator method getMappedBy.
private String getMappedBy(Collection collectionValue) {
final PersistentClass referencedClass = getReferenceCollectionClass(collectionValue);
final ValueHolder valueHolder = new ValueHolder(collectionValue);
return getMappedBy(referencedClass, valueHolder);
}
use of org.hibernate.mapping.PersistentClass in project hibernate-orm by hibernate.
the class VersionsJoinTableRangeComponentNamingTest method testJoinColumnNamesComponent2.
@Test
public void testJoinColumnNamesComponent2() {
PersistentClass auditClass = metadata().getEntityBinding(COMPONENT_2_AUDIT_JOIN_TABLE_NAME);
assert auditClass != null;
@SuppressWarnings({ "unchecked" }) Iterator<Column> columns = auditClass.getTable().getColumnIterator();
boolean id1Found = false;
boolean id2Found = false;
while (columns.hasNext()) {
Column column = columns.next();
if ("VJTRCTE2_ID".equals(column.getName())) {
id1Found = true;
}
if ("VJTRTAE_ID".equals(column.getName())) {
id2Found = true;
}
}
assert id1Found && id2Found;
}
use of org.hibernate.mapping.PersistentClass in project hibernate-orm by hibernate.
the class VersionsJoinTableRangeComponentNamingTest method testOverrideNotAudited.
/**
* Verify that
* {@link VersionsJoinTableRangeComponentTestEntity#getComponent3()} is
* partially audited.
*/
@Test
public void testOverrideNotAudited() {
PersistentClass auditClass = metadata().getEntityBinding(VersionsJoinTableRangeComponentTestEntity.class.getName() + "_AUD");
assert auditClass != null;
@SuppressWarnings({ "unchecked" }) Iterator<Column> columns = auditClass.getTable().getColumnIterator();
boolean auditColumn1Found = false;
boolean auditColumn2Found = false;
while (columns.hasNext()) {
Column column = columns.next();
if ("STR1".equals(column.getName())) {
auditColumn1Found = true;
}
if ("STR2".equals(column.getName())) {
auditColumn2Found = true;
}
}
assert auditColumn1Found && !auditColumn2Found;
}
Aggregations