Example usage for org.hibernate.persister.entity Joinable getKeyColumnNames

List of usage examples for org.hibernate.persister.entity Joinable getKeyColumnNames

Introduction

In this page you can find the example usage for org.hibernate.persister.entity Joinable getKeyColumnNames.

Prototype

public String[] getKeyColumnNames();

Source Link

Document

The columns to join on

Usage

From source file:org.web4thejob.orm.PropertyMetadataImpl.java

License:Open Source License

@Override
public boolean isAssociatedWith(PropertyMetadata propertyMetadata) {
    if (!(isAssociationType() && propertyMetadata.isAssociationType())) {
        return false;
    } else if (!getAssociatedEntityMetadata().getEntityType()
            .isAssignableFrom(propertyMetadata.getEntityMetadata().getEntityType())) {
        return false;
    } else if (isOneToOneType() && propertyMetadata.isOneToOneType()) {
        // OneToOne has no columns so since the entity type is the same
        // (checked above) it is safe to assume that properties are
        // associated.
        return true;
    } else if (!propertyMetadata.hasColumns()) {
        return propertyMetadata.isAssociatedWith(this);
    }//from w  ww  .  java2 s  .c o  m

    final Joinable j = ((AssociationType) property.getType())
            .getAssociatedJoinable(ContextUtil.getBean(SessionFactoryImplementor.class));

    for (final String p : j.getKeyColumnNames()) {
        String p2 = p.replaceAll("\"", "");
        p2 = p2.replaceAll("`", "");
        if (propertyMetadata.hasColumn(p2)) {
            return true;
        }
    }

    return false;
}