Example usage for org.hibernate.persister.entity AbstractEntityPersister getEntityName

List of usage examples for org.hibernate.persister.entity AbstractEntityPersister getEntityName

Introduction

In this page you can find the example usage for org.hibernate.persister.entity AbstractEntityPersister getEntityName.

Prototype

public final String getEntityName() 

Source Link

Usage

From source file:com.blazebit.persistence.integration.hibernate.base.HibernateJpaProvider.java

License:Apache License

private Set<String> removeIdentifierAccess(EntityType<?> elementType, Set<String> elementAttributeNames,
        EntityType<?> ownerType, Set<String> columnMatchingAttributeNames) {
    Set<String> set = new LinkedHashSet<>();
    Iterator<String> iterator = elementAttributeNames.iterator();
    AbstractEntityPersister elementPersister = getEntityPersister(elementType);
    AbstractEntityPersister entityPersister = getEntityPersister(ownerType);
    List<String> addedAttributeNames = new ArrayList<>();
    for (String attributeName : columnMatchingAttributeNames) {
        String elementAttributeName = iterator.next();
        Type propertyType = entityPersister.getPropertyType(attributeName);
        if (propertyType instanceof org.hibernate.type.EntityType) {
            // If the columns refer to an association, we map that through instead of trying to set just the identifier properties
            if (elementPersister.getEntityName()
                    .equals(((org.hibernate.type.EntityType) propertyType).getAssociatedEntityName())) {
                List<String> identifierPropertyNames = getIdentifierOrUniqueKeyEmbeddedPropertyNames(ownerType,
                        attributeName);// w w w .  ja  va 2s.  c  om
                iterator.remove();
                for (int i = 1; i < identifierPropertyNames.size(); i++) {
                    iterator.next();
                    iterator.remove();
                }
                addedAttributeNames.add(attributeName);
            }
        } else {
            set.add(attributeName);
        }
    }

    for (String addedAttributeName : addedAttributeNames) {
        set.add(addedAttributeName);
        elementAttributeNames.add("");
    }

    return set;
}