Example usage for org.hibernate.persister.collection CollectionPersister isInverse

List of usage examples for org.hibernate.persister.collection CollectionPersister isInverse

Introduction

In this page you can find the example usage for org.hibernate.persister.collection CollectionPersister isInverse.

Prototype

boolean isInverse();

Source Link

Document

Is this collection "inverse", so state changes are not propogated to the database.

Usage

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

License:Apache License

@Override
public String getMappedBy(EntityType<?> ownerType, String attributeName) {
    CollectionPersister persister = getCollectionPersister(ownerType, attributeName);
    if (persister != null) {
        if (persister.isInverse()) {
            return getMappedBy(persister);
        } else if (persister instanceof OneToManyPersister) {
            // A one-to-many association without a join table is like an inverse association
            return "";
        }//from w  ww  . j ava 2  s  . c  o  m
    } else {
        EntityPersister entityPersister = getEntityPersister(ownerType);
        Type propertyType = entityPersister.getPropertyType(attributeName);
        if (propertyType instanceof OneToOneType) {
            return ((OneToOneType) propertyType).getRHSUniqueKeyPropertyName();
        }
    }
    return null;
}

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

License:Apache License

@Override
public boolean isBag(EntityType<?> ownerType, String attributeName) {
    CollectionPersister persister = null;
    IdentifiableType<?> type = ownerType;
    String typeName = getTypeName(ownerType);
    StringBuilder sb = new StringBuilder(typeName.length() + attributeName.length() + 1);
    while (persister == null && type != null) {
        sb.setLength(0);/*w w w. j av a2 s.  c o m*/
        sb.append(getTypeName(type));
        sb.append('.');
        sb.append(attributeName);
        persister = collectionPersisters.get(sb.toString());
        type = type.getSupertype();
    }

    return persister != null && !persister.hasIndex() && !persister.isInverse()
            && !(getAttribute(ownerType, attributeName) instanceof SetAttribute<?, ?>);
}

From source file:org.riotfamily.common.web.cache.hibernate.CacheTagInterceptor.java

License:Apache License

private boolean hasInverseCollection(ClassMetadata meta, Class<?> elementType) {
    SessionFactoryImplementor impl = (SessionFactoryImplementor) sessionFactory;
    for (Type type : meta.getPropertyTypes()) {
        if (type.isCollectionType()) {
            String role = ((CollectionType) type).getRole();
            CollectionPersister persister = impl.getCollectionPersister(role);
            return persister.isInverse() && persister.getElementType().getReturnedClass().equals(elementType);
        }//from  w w w  . j a  v  a  2 s.  c o m
    }
    return false;
}