Java 类org.hibernate.annotations.JoinFormula 实例源码

项目:lams    文件:Ejb3JoinColumn.java   
public static Ejb3JoinColumn[] buildJoinColumnsOrFormulas(
        JoinColumnsOrFormulas anns,
        String mappedBy,
        Map<String, Join> joins,
        PropertyHolder propertyHolder,
        String propertyName,
        Mappings mappings) {
    JoinColumnOrFormula [] ann = anns.value();
    Ejb3JoinColumn [] joinColumns = new Ejb3JoinColumn[ann.length];
    for (int i = 0; i < ann.length; i++) {
        JoinColumnOrFormula join = ann[i];
        JoinFormula formula = join.formula();
        if (formula.value() != null && !formula.value().equals("")) {
            joinColumns[i] = buildJoinFormula(
                    formula, mappedBy, joins, propertyHolder, propertyName, mappings
            );
        }
        else {
            joinColumns[i] = buildJoinColumns(
                    new JoinColumn[] { join.column() }, mappedBy, joins, propertyHolder, propertyName, mappings
            )[0];
        }
    }

    return joinColumns;
}
项目:lams    文件:Ejb3JoinColumn.java   
/**
 * build join formula
 */
public static Ejb3JoinColumn buildJoinFormula(
        JoinFormula ann,
        String mappedBy,
        Map<String, Join> joins,
        PropertyHolder propertyHolder,
        String propertyName,
        Mappings mappings) {
    Ejb3JoinColumn formulaColumn = new Ejb3JoinColumn();
    formulaColumn.setFormula( ann.value() );
    formulaColumn.setReferencedColumn(ann.referencedColumnName());
    formulaColumn.setMappings( mappings );
    formulaColumn.setPropertyHolder( propertyHolder );
    formulaColumn.setJoins( joins );
    formulaColumn.setPropertyName( BinderHelper.getRelativePath( propertyHolder, propertyName ) );
    formulaColumn.bind();
    return formulaColumn;
}