Search in sources :

Example 1 with PersistentAttribute

use of org.eclipse.jpt.jpa.core.context.PersistentAttribute in project jbosstools-hibernate by jbosstools.

the class HibernateJavaJoinColumnImpl method getReferencedPersistentAttribute.

@Override
public PersistentAttribute getReferencedPersistentAttribute() {
    if (this.parentAdapter.getJoinColumnsSize() != 1) {
        return null;
    }
    Entity targetEntity = this.parentAdapter.getRelationshipTarget();
    if (targetEntity == null) {
        return null;
    }
    PersistentAttribute pAttr = null;
    Iterator<PersistentAttribute> attributes = targetEntity.getPersistentType().getAllAttributes().iterator();
    for (Iterator<PersistentAttribute> stream = attributes; stream.hasNext(); ) {
        PersistentAttribute attribute = stream.next();
        String name = attribute.getPrimaryKeyColumnName();
        if (name != null) {
            if (pAttr == null) {
                pAttr = attribute;
            } else {
                return null;
            }
        }
    }
    return pAttr;
}
Also used : Entity(org.eclipse.jpt.jpa.core.context.Entity) PersistentAttribute(org.eclipse.jpt.jpa.core.context.PersistentAttribute)

Example 2 with PersistentAttribute

use of org.eclipse.jpt.jpa.core.context.PersistentAttribute in project jbosstools-hibernate by jbosstools.

the class HibernateOrmJoinColumnImpl method getReferencedPersistentAttribute.

public PersistentAttribute getReferencedPersistentAttribute() {
    if (this.parentAdapter.getJoinColumnsSize() != 1) {
        return null;
    }
    Entity targetEntity = this.parentAdapter.getRelationshipTarget();
    if (targetEntity == null) {
        return null;
    }
    PersistentAttribute pAttr = null;
    for (PersistentAttribute attribute : targetEntity.getPersistentType().getAllAttributes()) {
        String name = attribute.getPrimaryKeyColumnName();
        if (name != null) {
            if (pAttr == null) {
                pAttr = attribute;
            } else {
                return null;
            }
        }
    }
    return pAttr;
}
Also used : Entity(org.eclipse.jpt.jpa.core.context.Entity) PersistentAttribute(org.eclipse.jpt.jpa.core.context.PersistentAttribute)

Aggregations

Entity (org.eclipse.jpt.jpa.core.context.Entity)2 PersistentAttribute (org.eclipse.jpt.jpa.core.context.PersistentAttribute)2