use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class SchemaValidatorTask method execute.
/**
* Execute the task
*/
@Override
public void execute() throws BuildException {
try {
final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder();
configure(ssrBuilder);
final StandardServiceRegistry ssr = ssrBuilder.build();
try {
final MetadataSources metadataSources = new MetadataSources(ssrBuilder.build());
configure(metadataSources);
final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder();
configure(metadataBuilder, ssr);
final MetadataImplementor metadata = (MetadataImplementor) metadataBuilder.build();
new SchemaValidator().validate(metadata, ssr);
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
} catch (HibernateException e) {
throw new BuildException("Schema text failed: " + e.getMessage(), e);
} catch (FileNotFoundException e) {
throw new BuildException("File not found: " + e.getMessage(), e);
} catch (IOException e) {
throw new BuildException("IOException : " + e.getMessage(), e);
} catch (BuildException e) {
throw e;
} catch (Exception e) {
throw new BuildException(e);
}
}
use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class ConfigurationTest method testSharedCacheModeUnspecified.
@Test
public void testSharedCacheModeUnspecified() {
MetadataImplementor metadata = buildMetadata(SharedCacheMode.UNSPECIFIED);
PersistentClass pc = metadata.getEntityBinding(ExplicitlyCacheableEntity.class.getName());
assertNull(pc.getCacheConcurrencyStrategy());
pc = metadata.getEntityBinding(ExplicitlyNonCacheableEntity.class.getName());
assertNull(pc.getCacheConcurrencyStrategy());
pc = metadata.getEntityBinding(NoCacheableAnnotationEntity.class.getName());
assertNull(pc.getCacheConcurrencyStrategy());
}
use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class ConfigurationTest method testSharedCacheModeEnable.
@Test
public void testSharedCacheModeEnable() {
MetadataImplementor metadata = buildMetadata(SharedCacheMode.ENABLE_SELECTIVE);
PersistentClass pc = metadata.getEntityBinding(ExplicitlyCacheableEntity.class.getName());
assertNotNull(pc.getCacheConcurrencyStrategy());
pc = metadata.getEntityBinding(ExplicitlyNonCacheableEntity.class.getName());
assertNull(pc.getCacheConcurrencyStrategy());
pc = metadata.getEntityBinding(NoCacheableAnnotationEntity.class.getName());
assertNull(pc.getCacheConcurrencyStrategy());
}
use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class ConfigurationTest method testSharedCacheModeDisable.
@Test
public void testSharedCacheModeDisable() {
MetadataImplementor metadata = buildMetadata(SharedCacheMode.DISABLE_SELECTIVE);
PersistentClass pc = metadata.getEntityBinding(ExplicitlyCacheableEntity.class.getName());
assertNotNull(pc.getCacheConcurrencyStrategy());
pc = metadata.getEntityBinding(ExplicitlyNonCacheableEntity.class.getName());
assertNull(pc.getCacheConcurrencyStrategy());
pc = metadata.getEntityBinding(NoCacheableAnnotationEntity.class.getName());
assertNotNull(pc.getCacheConcurrencyStrategy());
}
use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.
the class EnumeratedSmokeTest method testEnumeratedTypeResolutions.
/**
* I personally have been unable to repeoduce the bug as reported in HHH-10402. This test
* is equivalent to what the reporters say happens, but these tests pass fine.
*/
@Test
@TestForIssue(jiraKey = "HHH-10402")
public void testEnumeratedTypeResolutions() {
final MetadataImplementor mappings = (MetadataImplementor) new MetadataSources(ssr).addAnnotatedClass(EntityWithEnumeratedAttributes.class).buildMetadata();
mappings.validate();
final PersistentClass entityBinding = mappings.getEntityBinding(EntityWithEnumeratedAttributes.class.getName());
validateEnumMapping(entityBinding.getProperty("notAnnotated"), EnumType.ORDINAL);
validateEnumMapping(entityBinding.getProperty("noEnumType"), EnumType.ORDINAL);
validateEnumMapping(entityBinding.getProperty("ordinalEnumType"), EnumType.ORDINAL);
validateEnumMapping(entityBinding.getProperty("stringEnumType"), EnumType.STRING);
}
Aggregations