当前位置: 首页>>代码示例>>Java>>正文


Java EntityRelation类代码示例

本文整理汇总了Java中org.netbeans.modules.j2ee.persistence.entitygenerator.EntityRelation的典型用法代码示例。如果您正苦于以下问题:Java EntityRelation类的具体用法?Java EntityRelation怎么用?Java EntityRelation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EntityRelation类属于org.netbeans.modules.j2ee.persistence.entitygenerator包,在下文中一共展示了EntityRelation类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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 (int i = 0; i < r.length; i++) {
        r[i].makeRoleNamesUnique();
        String baseName = r[i].getRelationName();
        r[i].setRelationName(uniqueAlgorithm(relationNames, baseName, "-")); // NOI18N
    }
    return r;
}
 
开发者ID:foxerfly,项目名称:Netbeans-JPA-Modeler,代码行数:14,代码来源:DbSchemaEjbGenerator.java

示例3: getRelations

import org.netbeans.modules.j2ee.persistence.entitygenerator.EntityRelation; //导入依赖的package包/类
public EntityRelation[] getRelations() {
    return generator.getRelations();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:RelatedCMPHelper.java

示例4: getRelations

import org.netbeans.modules.j2ee.persistence.entitygenerator.EntityRelation; //导入依赖的package包/类
public EntityRelation[] getRelations() {
    return (EntityRelation[]) relations.toArray(new EntityRelation[relations.size()]);
}
 
开发者ID:jeddict,项目名称:jeddict,代码行数:4,代码来源:DbSchemaEjbGenerator.java

示例5: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。