本文整理汇总了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;
}
示例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));
}