Example usage for org.hibernate.mapping SimpleValue getForeignKeyName

List of usage examples for org.hibernate.mapping SimpleValue getForeignKeyName

Introduction

In this page you can find the example usage for org.hibernate.mapping SimpleValue getForeignKeyName.

Prototype

public String getForeignKeyName() 

Source Link

Usage

From source file:org.jboss.tools.hibernate.ui.diagram.editors.model.Utils.java

License:Open Source License

public static String getName(Object obj) {
    String res = ""; //$NON-NLS-1$
    if (obj instanceof PersistentClass) {
        PersistentClass rootClass = (PersistentClass) obj;
        if (rootClass.getEntityName() != null) {
            res = rootClass.getEntityName();
        } else {// w ww.  j  ava 2 s. c om
            res = rootClass.getClassName();
        }
    } else if (obj instanceof Table) {
        res = getTableName((Table) obj);
    } else if (obj instanceof Property) {
        Property property = (Property) obj;
        res = getName(property.getPersistentClass()) + "." + property.getName(); //$NON-NLS-1$
    } else if (obj instanceof SimpleValue) {
        SimpleValue sv = (SimpleValue) obj;
        res = getTableName(sv.getTable()) + "." + sv.getForeignKeyName(); //$NON-NLS-1$
    } else if (obj instanceof String) {
        res = (String) obj;
    }
    if (res.length() > 0 && res.indexOf(".") < 0) { //$NON-NLS-1$
        return "default." + res; //$NON-NLS-1$
    }
    if (res.length() == 0) {
        res = "null"; //$NON-NLS-1$
    }
    return res;
}