Example usage for org.hibernate.persister.collection OneToManyPersister getMappedByProperty

List of usage examples for org.hibernate.persister.collection OneToManyPersister getMappedByProperty

Introduction

In this page you can find the example usage for org.hibernate.persister.collection OneToManyPersister getMappedByProperty.

Prototype

@Override
    public String getMappedByProperty() 

Source Link

Usage

From source file:be.shad.tsqb.helper.TypeSafeQueryHelperImpl.java

License:Apache License

/**
 *
 *///w  ww . j  a  v  a 2 s .c o m
@Override
public String getMappedByProperty(TypeSafeQueryProxyData child) {
    Type propertyType = getTargetType(child.getParent(), child.getPropertyPath());
    if (!propertyType.isCollectionType()) {
        throw new IllegalArgumentException("Method not designed to fetch MappedByProperty "
                + "for a non-collection type. PropertyType was: " + propertyType);
    }

    CollectionMetadata collectionMetadata = (CollectionMetadata) metaModel
            .collectionPersister(((CollectionType) propertyType).getRole());
    if (collectionMetadata instanceof OneToManyPersister) {
        OneToManyPersister persister = (OneToManyPersister) collectionMetadata;
        return persister.getMappedByProperty();
    }
    // what about many to many?
    return null;
}