use of org.hibernate.mapping.Property in project hibernate-orm by hibernate.
the class Tests method testJpaJoinColumnPhysicalNaming.
@Test
@TestForIssue(jiraKey = "HHH-9961")
public void testJpaJoinColumnPhysicalNaming() {
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().applySettings(Environment.getProperties()).build();
try {
final MetadataSources metadataSources = new MetadataSources(ssr);
metadataSources.addAnnotatedClass(Language.class);
final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder();
metadataBuilder.applyImplicitNamingStrategy(ImplicitNamingStrategyJpaCompliantImpl.INSTANCE);
metadataBuilder.applyPhysicalNamingStrategy(PhysicalNamingStrategyImpl.INSTANCE);
final Metadata metadata = metadataBuilder.build();
((MetadataImplementor) metadata).validate();
final PersistentClass languageBinding = metadata.getEntityBinding(Language.class.getName());
final Property property = languageBinding.getProperty("fallBack");
Iterator itr = property.getValue().getColumnIterator();
assertTrue(itr.hasNext());
final Column column = (Column) itr.next();
assertFalse(itr.hasNext());
assertEquals("C_FALLBACK_ID", column.getName().toUpperCase(Locale.ROOT));
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.mapping.Property in project hibernate-orm by hibernate.
the class SimpleNationalizedTest method simpleNationalizedTest.
@Test
public void simpleNationalizedTest() {
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
try {
final MetadataSources ms = new MetadataSources(ssr);
ms.addAnnotatedClass(NationalizedEntity.class);
final Metadata metadata = ms.buildMetadata();
PersistentClass pc = metadata.getEntityBinding(NationalizedEntity.class.getName());
assertNotNull(pc);
Property prop = pc.getProperty("nvarcharAtt");
if (metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect) {
// See issue HHH-10693
assertSame(StringType.INSTANCE, prop.getType());
} else {
assertSame(StringNVarcharType.INSTANCE, prop.getType());
}
prop = pc.getProperty("materializedNclobAtt");
if (metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect) {
// See issue HHH-10693
assertSame(MaterializedClobType.INSTANCE, prop.getType());
} else {
assertSame(MaterializedNClobType.INSTANCE, prop.getType());
}
prop = pc.getProperty("nclobAtt");
assertSame(NClobType.INSTANCE, prop.getType());
prop = pc.getProperty("nlongvarcharcharAtt");
assertSame(NTextType.INSTANCE, prop.getType());
prop = pc.getProperty("ncharArrAtt");
if (metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect) {
// See issue HHH-10693
assertSame(CharacterArrayType.INSTANCE, prop.getType());
} else {
assertSame(StringNVarcharType.INSTANCE, prop.getType());
}
prop = pc.getProperty("ncharacterAtt");
if (metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect) {
// See issue HHH-10693
assertSame(CharacterType.INSTANCE, prop.getType());
} else {
assertSame(CharacterNCharType.INSTANCE, prop.getType());
}
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.mapping.Property in project hibernate-orm by hibernate.
the class BaseNamingTests method validateZipCode.
protected void validateZipCode(Metadata metadata) {
final PersistentClass zipCodeBinding = metadata.getEntityBinding(ZipCode.class.getName());
assertNotNull(zipCodeBinding);
validateZipCodePrimaryTableName(zipCodeBinding.getTable().getQuotedName());
assertEquals(1, zipCodeBinding.getIdentifier().getColumnSpan());
validateZipCodePrimaryKeyColumn((Column) zipCodeBinding.getIdentifier().getColumnIterator().next());
final Property codeBinding = zipCodeBinding.getProperty("code");
assertNotNull(codeBinding);
assertEquals(1, codeBinding.getColumnSpan());
validateZipCodeCodeColumn((Column) codeBinding.getColumnIterator().next());
final Property cityBinding = zipCodeBinding.getProperty("city");
assertNotNull(cityBinding);
assertEquals(1, cityBinding.getColumnSpan());
validateZipCodeCityColumn((Column) cityBinding.getColumnIterator().next());
final Property stateBinding = zipCodeBinding.getProperty("state");
assertNotNull(stateBinding);
assertEquals(1, stateBinding.getColumnSpan());
validateZipCodeStateColumn((Column) stateBinding.getColumnIterator().next());
}
use of org.hibernate.mapping.Property in project hibernate-orm by hibernate.
the class BaseNamingTests method validateOrder.
protected void validateOrder(Metadata metadata) {
final PersistentClass orderBinding = metadata.getEntityBinding(Order.class.getName());
assertNotNull(orderBinding);
validateOrderPrimaryTableName(orderBinding.getTable().getQuotedName());
assertEquals(1, orderBinding.getIdentifier().getColumnSpan());
validateOrderPrimaryKeyColumn((Column) orderBinding.getIdentifier().getColumnIterator().next());
final Property referenceCodeBinding = orderBinding.getProperty("referenceCode");
assertNotNull(referenceCodeBinding);
assertEquals(1, referenceCodeBinding.getColumnSpan());
validateOrderReferenceCodeColumn((Column) referenceCodeBinding.getColumnIterator().next());
final Property placedBinding = orderBinding.getProperty("placed");
assertNotNull(placedBinding);
assertEquals(1, placedBinding.getColumnSpan());
validateOrderPlacedColumn((Column) placedBinding.getColumnIterator().next());
final Property fulfilledBinding = orderBinding.getProperty("fulfilled");
assertNotNull(fulfilledBinding);
assertEquals(1, fulfilledBinding.getColumnSpan());
validateOrderFulfilledColumn((Column) fulfilledBinding.getColumnIterator().next());
final Property customerBinding = orderBinding.getProperty("customer");
assertNotNull(customerBinding);
assertEquals(1, customerBinding.getColumnSpan());
validateOrderCustomerColumn((Column) customerBinding.getColumnIterator().next());
}
use of org.hibernate.mapping.Property in project hibernate-orm by hibernate.
the class PersistentClassTest method testGetProperty.
@Test
public void testGetProperty() {
RootClass pc = new RootClass(metadataBuildingContext);
Property p = new Property();
p.setName("name");
pc.addProperty(p);
Assert.assertEquals(p, pc.getProperty("name"));
Assert.assertEquals(p, pc.getProperty("name.test"));
try {
Assert.assertNull(pc.getProperty("test"));
Assert.fail("MappingException expected");
} catch (MappingException e) {
// expected
}
}
Aggregations