Search in sources :

Example 41 with Property

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

the class AuditedPropertiesReader method createPropertiesGroupMapping.

@SuppressWarnings("unchecked")
private void createPropertiesGroupMapping(Property property) {
    final Component component = (Component) property.getValue();
    final Iterator<Property> componentProperties = component.getPropertyIterator();
    while (componentProperties.hasNext()) {
        final Property componentProperty = componentProperties.next();
        propertiesGroupMapping.put(componentProperty.getName(), property.getName());
    }
}
Also used : Component(org.hibernate.mapping.Component) Property(org.hibernate.mapping.Property) XProperty(org.hibernate.annotations.common.reflection.XProperty)

Example 42 with Property

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

the class AuditedPropertiesReader method readPersistentPropertiesAccess.

private void readPersistentPropertiesAccess() {
    final Iterator<Property> propertyIter = persistentPropertiesSource.getPropertyIterator();
    while (propertyIter.hasNext()) {
        final Property property = propertyIter.next();
        addPersistentProperty(property);
        // See HHH-6636
        if ("embedded".equals(property.getPropertyAccessorName()) && !PropertyPath.IDENTIFIER_MAPPER_PROPERTY.equals(property.getName())) {
            createPropertiesGroupMapping(property);
        }
    }
}
Also used : Property(org.hibernate.mapping.Property) XProperty(org.hibernate.annotations.common.reflection.XProperty)

Example 43 with Property

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

the class Java8DateTimeTests method dump.

private void dump(PersistentClass entityBinding, TheEntity theEntity) {
    final Iterator propertyBindingIterator = entityBinding.getPropertyClosureIterator();
    while (propertyBindingIterator.hasNext()) {
        final Property propertyBinding = (Property) propertyBindingIterator.next();
        final JavaTypeDescriptor javaTypeDescriptor = ((AbstractStandardBasicType) propertyBinding.getType()).getJavaTypeDescriptor();
        System.out.println(String.format("%s (%s) -> %s", propertyBinding.getName(), javaTypeDescriptor.getJavaTypeClass().getSimpleName(), javaTypeDescriptor.toString(propertyBinding.getGetter(TheEntity.class).get(theEntity))));
    }
}
Also used : Iterator(java.util.Iterator) Property(org.hibernate.mapping.Property) JavaTypeDescriptor(org.hibernate.type.descriptor.java.JavaTypeDescriptor) AbstractStandardBasicType(org.hibernate.type.AbstractStandardBasicType)

Example 44 with Property

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

the class ClassesAuditingData method updateCalculatedFields.

/**
	 * After all meta-data is read, updates calculated fields. This includes:
	 * <ul>
	 * <li>setting {@code forceInsertable} to {@code true} for properties specified by {@code @AuditMappedBy}</li>
	 * <li>adding {@code synthetic} properties to mappedBy relations which have {@code IndexColumn} or {@code OrderColumn}.</li>
	 * </ul>
	 */
public void updateCalculatedFields() {
    for (Map.Entry<PersistentClass, ClassAuditingData> classAuditingDataEntry : persistentClassToAuditingData.entrySet()) {
        final PersistentClass pc = classAuditingDataEntry.getKey();
        final ClassAuditingData classAuditingData = classAuditingDataEntry.getValue();
        for (String propertyName : classAuditingData.getNonSyntheticPropertyNames()) {
            final Property property = pc.getProperty(propertyName);
            updateCalculatedProperty(pc.getEntityName(), property, propertyName, classAuditingData);
        }
    }
}
Also used : ClassAuditingData(org.hibernate.envers.configuration.internal.metadata.reader.ClassAuditingData) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Property(org.hibernate.mapping.Property) PersistentClass(org.hibernate.mapping.PersistentClass)

Example 45 with Property

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

the class UnversionedOptimisticLockingField method testMapping.

@Test
public void testMapping() {
    PersistentClass pc = metadata().getEntityBinding(UnversionedOptimisticLockingFieldEntity.class.getName() + "_AUD");
    Iterator pi = pc.getPropertyIterator();
    while (pi.hasNext()) {
        Property p = (Property) pi.next();
        assert !"optLocking".equals(p.getName());
    }
}
Also used : Iterator(java.util.Iterator) Property(org.hibernate.mapping.Property) PersistentClass(org.hibernate.mapping.PersistentClass) Test(org.junit.Test)

Aggregations

Property (org.hibernate.mapping.Property)94 PersistentClass (org.hibernate.mapping.PersistentClass)53 Component (org.hibernate.mapping.Component)30 Test (org.junit.Test)29 SimpleValue (org.hibernate.mapping.SimpleValue)24 Iterator (java.util.Iterator)23 SyntheticProperty (org.hibernate.mapping.SyntheticProperty)18 MetadataSources (org.hibernate.boot.MetadataSources)17 Column (org.hibernate.mapping.Column)17 AnnotationException (org.hibernate.AnnotationException)14 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)14 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)14 XProperty (org.hibernate.annotations.common.reflection.XProperty)12 Metadata (org.hibernate.boot.Metadata)11 Collection (org.hibernate.mapping.Collection)11 HashMap (java.util.HashMap)10 AssertionFailure (org.hibernate.AssertionFailure)10 MappingException (org.hibernate.MappingException)9 TestForIssue (org.hibernate.testing.TestForIssue)9 Map (java.util.Map)7