Search in sources :

Example 66 with PersistentClass

use of org.hibernate.mapping.PersistentClass 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 67 with PersistentClass

use of org.hibernate.mapping.PersistentClass 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 68 with PersistentClass

use of org.hibernate.mapping.PersistentClass in project hibernate-orm by hibernate.

the class SimpleXmlOverriddenTest method baseline.

/**
 * A baseline test, with an explicit @Convert annotation that should be in effect
 */
@Test
public void baseline() {
    Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(TheEntity.class).buildMetadata();
    PersistentClass pc = metadata.getEntityBinding(TheEntity.class.getName());
    Type type = pc.getProperty("it").getType();
    AttributeConverterTypeAdapter adapter = assertTyping(AttributeConverterTypeAdapter.class, type);
    assertTrue(SillyStringConverter.class.isAssignableFrom(adapter.getAttributeConverter().getConverterJavaTypeDescriptor().getJavaType()));
}
Also used : StringType(org.hibernate.type.StringType) Type(org.hibernate.type.Type) Metadata(org.hibernate.boot.Metadata) MetadataSources(org.hibernate.boot.MetadataSources) AttributeConverterTypeAdapter(org.hibernate.type.descriptor.converter.AttributeConverterTypeAdapter) PersistentClass(org.hibernate.mapping.PersistentClass) Test(org.junit.Test)

Example 69 with PersistentClass

use of org.hibernate.mapping.PersistentClass in project hibernate-orm by hibernate.

the class SimpleXmlOverriddenTest method testDefinitionAtAttributeLevel.

/**
 * Test outcome of applying overrides via orm.xml, specifically at the attribute level
 */
@Test
public void testDefinitionAtAttributeLevel() {
    // NOTE : simple-override.xml applied disable-conversion="true" at the attribute-level
    Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(TheEntity.class).addResource("org/hibernate/test/converter/simple-override.xml").buildMetadata();
    PersistentClass pc = metadata.getEntityBinding(TheEntity.class.getName());
    Type type = pc.getProperty("it").getType();
    assertTyping(StringType.class, type);
}
Also used : StringType(org.hibernate.type.StringType) Type(org.hibernate.type.Type) Metadata(org.hibernate.boot.Metadata) MetadataSources(org.hibernate.boot.MetadataSources) PersistentClass(org.hibernate.mapping.PersistentClass) Test(org.junit.Test)

Example 70 with PersistentClass

use of org.hibernate.mapping.PersistentClass in project hibernate-orm by hibernate.

the class ParameterizedAttributeConverterParameterTypeTest method testNestedTypeParameterAutoApplication.

@Test
@TestForIssue(jiraKey = "HHH-10050")
public void testNestedTypeParameterAutoApplication() {
    final Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(SampleEntity.class).getMetadataBuilder().applyAttributeConverter(IntegerListConverter.class).applyAttributeConverter(StringListConverter.class).build();
    // lets make sure the auto-apply converters were applied properly...
    PersistentClass pc = metadata.getEntityBinding(SampleEntity.class.getName());
    {
        Property prop = pc.getProperty("someStrings");
        AttributeConverterTypeAdapter type = assertTyping(AttributeConverterTypeAdapter.class, prop.getType());
        assertTrue(StringListConverter.class.isAssignableFrom(type.getAttributeConverter().getConverterJavaTypeDescriptor().getJavaType()));
    }
    {
        Property prop = pc.getProperty("someIntegers");
        AttributeConverterTypeAdapter type = assertTyping(AttributeConverterTypeAdapter.class, prop.getType());
        assertTrue(IntegerListConverter.class.isAssignableFrom(type.getAttributeConverter().getConverterJavaTypeDescriptor().getJavaType()));
    }
}
Also used : Metadata(org.hibernate.boot.Metadata) MetadataSources(org.hibernate.boot.MetadataSources) AttributeConverterTypeAdapter(org.hibernate.type.descriptor.converter.AttributeConverterTypeAdapter) Property(org.hibernate.mapping.Property) PersistentClass(org.hibernate.mapping.PersistentClass) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Aggregations

PersistentClass (org.hibernate.mapping.PersistentClass)229 Test (org.junit.Test)121 Property (org.hibernate.mapping.Property)65 MetadataSources (org.hibernate.boot.MetadataSources)53 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)52 RootClass (org.hibernate.mapping.RootClass)50 Metadata (org.hibernate.boot.Metadata)45 Column (org.hibernate.mapping.Column)43 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)42 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)38 Iterator (java.util.Iterator)30 SimpleValue (org.hibernate.mapping.SimpleValue)24 HashMap (java.util.HashMap)22 Collection (org.hibernate.mapping.Collection)21 MappingException (org.hibernate.MappingException)20 MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)20 Table (org.hibernate.mapping.Table)20 Map (java.util.Map)19 ArrayList (java.util.ArrayList)18 TestForIssue (org.hibernate.testing.TestForIssue)18