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

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

Introduction

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

Prototype

public int getSubclassPropertyTableNumber(String propertyPath) 

Source Link

Document

Warning: When there are duplicated property names in the subclasses of the class, this method may return the wrong table number for the duplicated subclass property (note that SingleTableEntityPersister defines an overloaded form which takes the entity name.

Usage

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

License:Apache License

@Override
public boolean isForeignJoinColumn(EntityType<?> ownerType, String attributeName) {
    AbstractEntityPersister persister = getEntityPersister(ownerType);
    Type propertyType = persister.getPropertyType(attributeName);

    if (propertyType instanceof OneToOneType) {
        OneToOneType oneToOneType = (OneToOneType) propertyType;
        // It is foreign if there is a mapped by attribute
        // But as of Hibernate 5.4 we noticed that we have to treat nullable one-to-ones as "foreign" as well
        return (oneToOneType).getRHSUniqueKeyPropertyName() != null || isNullable(oneToOneType);
    }/*  w  w w .  j a v  a 2s .  com*/

    // Every entity persister has "owned" properties on table number 0, others have higher numbers
    int tableNumber = persister.getSubclassPropertyTableNumber(attributeName);
    return tableNumber >= persister.getEntityMetamodel().getSubclassEntityNames().size();
}