use of org.hibernate.mapping.PersistentClass in project hibernate-orm by hibernate.
the class CollectionAsBasicTest method testCollectionAsBasic.
@Test
public void testCollectionAsBasic() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
try {
Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(Post.class).getMetadataBuilder().applyBasicType(new DelimitedStringsType()).build();
PersistentClass postBinding = metadata.getEntityBinding(Post.class.getName());
Property tagsAttribute = postBinding.getProperty("tags");
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.mapping.PersistentClass in project hibernate-orm by hibernate.
the class BasicAttributeOverrideTest method testIt.
@Test
@TestForIssue(jiraKey = "HHH-8630")
public void testIt() {
final PersistentClass entityBinding = metadata().getEntityBinding(AggregatedTypeValue.class.getName());
final Property attributesBinding = entityBinding.getProperty("attributes");
final org.hibernate.mapping.Map attributesMap = (org.hibernate.mapping.Map) attributesBinding.getValue();
final SimpleValue mapKey = assertTyping(SimpleValue.class, attributesMap.getIndex());
final BasicType mapKeyType = assertTyping(BasicType.class, mapKey.getType());
assertTrue(String.class.equals(mapKeyType.getReturnedClass()));
// let's also make sure the @MapKeyColumn got applied
assertThat(mapKey.getColumnSpan(), is(1));
final org.hibernate.mapping.Column mapKeyColumn = assertTyping(org.hibernate.mapping.Column.class, mapKey.getColumnIterator().next());
assertThat(mapKeyColumn.getName(), equalTo("attribute_name"));
}
use of org.hibernate.mapping.PersistentClass in project hibernate-orm by hibernate.
the class EnumeratedWithMappedSuperclassTest method testHHH10128.
@Test
public void testHHH10128() {
final Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(Entity.class).addAnnotatedClass(DescriptionEntity.class).addAnnotatedClass(AddressLevel.class).buildMetadata();
final PersistentClass addressLevelBinding = metadata.getEntityBinding(AddressLevel.class.getName());
final Property natureProperty = addressLevelBinding.getProperty("nature");
CustomType customType = assertTyping(CustomType.class, natureProperty.getType());
EnumType enumType = assertTyping(EnumType.class, customType.getUserType());
assertEquals(Types.VARCHAR, enumType.sqlTypes()[0]);
SessionFactoryImplementor sf = (SessionFactoryImplementor) metadata.buildSessionFactory();
try {
EntityPersister p = sf.getEntityPersister(AddressLevel.class.getName());
CustomType runtimeType = assertTyping(CustomType.class, p.getPropertyType("nature"));
EnumType runtimeEnumType = assertTyping(EnumType.class, runtimeType.getUserType());
assertEquals(Types.VARCHAR, runtimeEnumType.sqlTypes()[0]);
} finally {
sf.close();
}
}
use of org.hibernate.mapping.PersistentClass 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);
}
use of org.hibernate.mapping.PersistentClass in project hibernate-orm by hibernate.
the class SerializableToBlobTypeTest method testTypeDefinition.
@Test
public void testTypeDefinition() {
PersistentClass pc = metadata().getEntityBinding(EntitySerialize.class.getName());
// explicitLob of SerializableToBlobType
Type explicitLobType = pc.getProperty("explicitLob").getType();
assertEquals(ExplicitSerializable.class, explicitLobType.getReturnedClass());
assertEquals(SerializableToBlobType.class.getName(), explicitLobType.getName());
// explicit of ExplicitSerializableType
Type explicitType = pc.getProperty("explicit").getType();
assertEquals(ExplicitSerializable.class, explicitType.getReturnedClass());
assertEquals(ExplicitSerializableType.class.getName(), explicitType.getName());
// implicit of ImplicitSerializableType
Type implicitType = pc.getProperty("implicit").getType();
assertEquals(ImplicitSerializable.class, implicitType.getReturnedClass());
assertEquals(ImplicitSerializableType.class.getName(), implicitType.getName());
// explicitOverridingImplicit ExplicitSerializableType overrides ImplicitSerializableType
Type overrideType = pc.getProperty("explicitOverridingImplicit").getType();
assertEquals(ImplicitSerializable.class, overrideType.getReturnedClass());
assertEquals(ExplicitSerializableType.class.getName(), overrideType.getName());
}
Aggregations