當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityRelation.setRelationName方法代碼示例

本文整理匯總了Java中org.netbeans.modules.j2ee.persistence.entitygenerator.EntityRelation.setRelationName方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityRelation.setRelationName方法的具體用法?Java EntityRelation.setRelationName怎麽用?Java EntityRelation.setRelationName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.netbeans.modules.j2ee.persistence.entitygenerator.EntityRelation的用法示例。


在下文中一共展示了EntityRelation.setRelationName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: makeRelationsUnique

import org.netbeans.modules.j2ee.persistence.entitygenerator.EntityRelation; //導入方法依賴的package包/類
/**
 * This method will make the relationships unique
 */
private EntityRelation[] makeRelationsUnique() {
    EntityRelation[] r = getRelations();
    List relationNames = new ArrayList(r.length);
    for (EntityRelation r1 : r) {
        r1.makeRoleNamesUnique();
        String baseName = r1.getRelationName();
        r1.setRelationName(uniqueAlgorithm(relationNames, baseName, "-")); // NOI18N
    }
    return r;
}
 
開發者ID:jeddict,項目名稱:jeddict,代碼行數:14,代碼來源:DbSchemaEjbGenerator.java

示例2: generateRelationship

import org.netbeans.modules.j2ee.persistence.entitygenerator.EntityRelation; //導入方法依賴的package包/類
private void generateRelationship(ForeignKeyElement key) {
        String keyTableName = key.getDeclaringTable().getName().getName();
        String keyRefName = key.getReferencedTable().getName().getName();
        boolean oneToOne = isFkUnique(key);
        EntityClass roleAHelper = getBean(keyTableName);
        if (roleAHelper == null) {
            return;
        }

        EntityClass roleBHelper = getBean(keyRefName);
        if (roleBHelper == null) {
            if (generateUnresolvedRelationships) {
                //we may want to generate field instead of skip
                for (ColumnElement col : key.getLocalColumns()) {
                    generatePkField(col, false, false);
                }
            }
            return;
        }

        // create role B (it's the table which contains the foreign key)
        String roleBCmr = EntityMember.makeRelationshipFieldName(
                roleAHelper.getClassName(), colectionType, !oneToOne);
        roleBCmr = uniqueAlgorithm(getFieldNames(roleBHelper), roleBCmr, null);
        RelationshipRole roleB = new RelationshipRole(
                //TODO ask generator for default role name, do not assume it is EJB name
                getRoleName(key, roleBHelper.getClassName()),
                roleBHelper.getClassName(),
                roleBCmr,
                false,
                !oneToOne,
                !isNullable(key),
                isNullable(key));
        roleB.setEntityPkgName(roleBHelper.getPackage());
        roleBHelper.addRole(roleB);

        // role A
        String roleACmr = EntityMember.makeRelationshipFieldName(
                roleBHelper.getClassName(), colectionType, false);

        /* only use database column name if a column is not required by the
         primary key. If a column is already required by the primary key
         then executing this code would cause the cmr-field name to be
         named cmp-fieldname1. Therefore, we do not change the cmr-field
         name and instead use the name of the other ejb (default).
         */
//        #185253 I don't see a good reason to have one case when it's possible to use column name and anothe case when it's not possible
//        comment code below for now, may need review or deletion in next release if there will be any negative feedback
//        #188550 add backward compartible option to have column names instead of tables names
        if (useColumNamesInRelations && !containsColumns(key.getColumns(), getPrimaryOrCandidateKey(key.getDeclaringTable()))) {
            roleACmr = EntityMember.makeRelationshipFieldName(roleB.getRoleName(), colectionType, false);
        }

        roleACmr = uniqueAlgorithm(getFieldNames(roleAHelper), roleACmr, null);

        RelationshipRole roleA = new RelationshipRole(
                //TODO ask generator for default role name, do not assume it is EJB name
                getRoleName(key, roleAHelper.getClassName()),
                roleAHelper.getClassName(),
                roleACmr,
                !oneToOne,
                false,
                false,
                isNullable(key));
        roleA.setEntityPkgName(roleAHelper.getPackage());
        roleAHelper.addRole(roleA);

        EntityRelation relation = new EntityRelation(roleA, roleB);
        relation.setRelationName(roleA.getEntityName() + '-' + roleB.getEntityName()); // NOI18N
        relations.add(relation);

        roleAHelper.getCMPMapping().getCmrFieldMapping().put(roleACmr, getLocalColumnData(key));
        roleBHelper.getCMPMapping().getCmrFieldMapping().put(roleBCmr, getReferencedColumnData(key));
    }
 
開發者ID:jeddict,項目名稱:jeddict,代碼行數:75,代碼來源:DbSchemaEjbGenerator.java


注:本文中的org.netbeans.modules.j2ee.persistence.entitygenerator.EntityRelation.setRelationName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。