Search in sources :

Example 6 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 7 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 8 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 9 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)

Example 10 with Property

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

the class AuditMetadataGenerator method addProperties.

private void addProperties(Element parent, Iterator<Property> properties, CompositeMapperBuilder currentMapper, ClassAuditingData auditingData, String entityName, EntityXmlMappingData xmlMappingData, boolean firstPass) {
    while (properties.hasNext()) {
        final Property property = properties.next();
        final String propertyName = property.getName();
        final PropertyAuditingData propertyAuditingData = auditingData.getPropertyAuditingData(propertyName);
        if (propertyAuditingData != null) {
            // and if so, this eliminates the mapping property as it isn't needed.
            if (property instanceof SyntheticProperty) {
                if (property.getValue().isAlternateUniqueKey()) {
                    continue;
                }
            }
            addValue(parent, property.getValue(), currentMapper, entityName, xmlMappingData, propertyAuditingData, isPropertyInsertable(property), firstPass, true);
        }
    }
}
Also used : SyntheticProperty(org.hibernate.mapping.SyntheticProperty) PropertyAuditingData(org.hibernate.envers.configuration.internal.metadata.reader.PropertyAuditingData) Property(org.hibernate.mapping.Property) SyntheticProperty(org.hibernate.mapping.SyntheticProperty)

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