Search in sources :

Example 46 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());
    assertTrue(pc.isCached());
    pc = metadata.getEntityBinding(ExplicitlyNonCacheableEntity.class.getName());
    assertFalse(pc.isCached());
    pc = metadata.getEntityBinding(NoCacheableAnnotationEntity.class.getName());
    assertTrue(pc.isCached());
}
Also used : MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) PersistentClass(org.hibernate.mapping.PersistentClass) Test(org.junit.Test)

Example 47 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());
    assertFalse(pc.isCached());
    pc = metadata.getEntityBinding(ExplicitlyNonCacheableEntity.class.getName());
    assertFalse(pc.isCached());
    pc = metadata.getEntityBinding(NoCacheableAnnotationEntity.class.getName());
    assertFalse(pc.isCached());
}
Also used : MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) PersistentClass(org.hibernate.mapping.PersistentClass) Test(org.junit.Test)

Example 48 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());
    assertTrue(pc.isCached());
    pc = metadata.getEntityBinding(ExplicitlyNonCacheableEntity.class.getName());
    assertFalse(pc.isCached());
    pc = metadata.getEntityBinding(NoCacheableAnnotationEntity.class.getName());
    assertFalse(pc.isCached());
}
Also used : MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) PersistentClass(org.hibernate.mapping.PersistentClass) Test(org.junit.Test)

Example 49 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)

Example 50 with MetadataImplementor

use of org.hibernate.boot.spi.MetadataImplementor in project hibernate-orm by hibernate.

the class SchemaUpdateTask method execute.

/**
 * Execute the task
 */
@Override
public void execute() throws BuildException {
    log("Running Hibernate Core SchemaUpdate.");
    log("This is an Ant task supporting only mapping files, if you want to use annotations see http://tools.hibernate.org.");
    try {
        final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder();
        configure(ssrBuilder);
        final StandardServiceRegistry ssr = ssrBuilder.build();
        final MetadataSources metadataSources = new MetadataSources(ssr);
        configure(metadataSources);
        final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder();
        configure(metadataBuilder, ssr);
        final MetadataImplementor metadata = (MetadataImplementor) metadataBuilder.build();
        new SchemaUpdate().setOutputFile(outputFile.getPath()).setDelimiter(delimiter).setHaltOnError(haltOnError).execute(TargetTypeHelper.parseLegacyCommandLineOptions(!quiet, !text, outputFile.getPath()), metadata);
    } 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)

Aggregations

MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)113 MetadataSources (org.hibernate.boot.MetadataSources)80 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)62 Test (org.junit.Test)56 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)52 SimpleValue (org.hibernate.mapping.SimpleValue)32 RootClass (org.hibernate.mapping.RootClass)31 PersistentClass (org.hibernate.mapping.PersistentClass)27 TestForIssue (org.hibernate.testing.TestForIssue)26 Table (org.hibernate.mapping.Table)23 Test (org.junit.jupiter.api.Test)23 SchemaExport (org.hibernate.tool.hbm2ddl.SchemaExport)22 SchemaUpdate (org.hibernate.tool.hbm2ddl.SchemaUpdate)20 Column (org.hibernate.mapping.Column)17 ArrayList (java.util.ArrayList)15 ServiceRegistry (org.hibernate.service.ServiceRegistry)15 File (java.io.File)14 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)14 Configuration (org.hibernate.cfg.Configuration)12 Property (org.hibernate.mapping.Property)11