Search in sources :

Example 11 with MetadataImplementor

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);
    }
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) MetadataBuilder(org.hibernate.boot.MetadataBuilder) HibernateException(org.hibernate.HibernateException) MetadataSources(org.hibernate.boot.MetadataSources) FileNotFoundException(java.io.FileNotFoundException) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) BuildException(org.apache.tools.ant.BuildException) IOException(java.io.IOException) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) FileNotFoundException(java.io.FileNotFoundException) HibernateException(org.hibernate.HibernateException) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry)

Example 12 with MetadataImplementor

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());
}
Also used : MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) PersistentClass(org.hibernate.mapping.PersistentClass) Test(org.junit.Test)

Example 13 with MetadataImplementor

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());
}
Also used : MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) PersistentClass(org.hibernate.mapping.PersistentClass) Test(org.junit.Test)

Example 14 with MetadataImplementor

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());
}
Also used : MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) PersistentClass(org.hibernate.mapping.PersistentClass) Test(org.junit.Test)

Example 15 with MetadataImplementor

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);
}
Also used : MetadataSources(org.hibernate.boot.MetadataSources) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) PersistentClass(org.hibernate.mapping.PersistentClass) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Aggregations

MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)67 MetadataSources (org.hibernate.boot.MetadataSources)58 Test (org.junit.Test)53 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)33 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)33 TestForIssue (org.hibernate.testing.TestForIssue)25 SchemaUpdate (org.hibernate.tool.hbm2ddl.SchemaUpdate)19 SchemaExport (org.hibernate.tool.hbm2ddl.SchemaExport)16 PersistentClass (org.hibernate.mapping.PersistentClass)15 File (java.io.File)13 MetadataBuilder (org.hibernate.boot.MetadataBuilder)7 Property (org.hibernate.mapping.Property)7 SimpleValue (org.hibernate.mapping.SimpleValue)7 Type (org.hibernate.type.Type)7 AbstractStandardBasicType (org.hibernate.type.AbstractStandardBasicType)6 BasicType (org.hibernate.type.BasicType)6 Metadata (org.hibernate.boot.Metadata)4 Namespace (org.hibernate.boot.model.relational.Namespace)4 Sequence (org.hibernate.boot.model.relational.Sequence)4 SchemaDropperImpl (org.hibernate.tool.schema.internal.SchemaDropperImpl)4