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


Java ForeignReferenceMapping类代码示例

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


ForeignReferenceMapping类属于org.eclipse.persistence.mappings包,在下文中一共展示了ForeignReferenceMapping类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildRelationTableDefinition

import org.eclipse.persistence.mappings.ForeignReferenceMapping; //导入依赖的package包/类
/**
     * Build relation table definitions for all many-to-many relationships in a
     * EclipseLink descriptor.
     */
    protected void buildRelationTableDefinition(ManagedClass managedClass, Attribute managedAttribute, LinkedList<Entity> intrinsicEntity, LinkedList<Attribute> intrinsicAttribute, boolean isInherited, ForeignReferenceMapping mapping, RelationTableMechanism relationTableMechanism, DatabaseField listOrderField, ContainerPolicy cp) {
        //first create relation table
        TableDefinition table = getTableDefFromDBTable(managedClass, managedAttribute, intrinsicEntity, relationTableMechanism.getRelationTable());

        //add source foreign key fields into the relation table
        List<DatabaseField> srcFkFields = relationTableMechanism.getSourceRelationKeyFields();//Relation Table
        List<DatabaseField> srcKeyFields = relationTableMechanism.getSourceKeyFields();//Entity(Owner) Table

        buildRelationTableFields(managedClass, managedAttribute, intrinsicEntity, intrinsicAttribute, false, isInherited, mapping, table, srcFkFields, srcKeyFields);

        //add target foreign key fields into the relation table
        List<DatabaseField> targFkFields = relationTableMechanism.getTargetRelationKeyFields();//Relation Table
        List<DatabaseField> targKeyFields = relationTableMechanism.getTargetKeyFields();//Entity(MappedBy) Table

//        attribute.getConnectedAttribute()
        buildRelationTableFields(managedClass, managedAttribute, intrinsicEntity, intrinsicAttribute, true, isInherited, mapping, table, targFkFields, targKeyFields);

        if (cp != null) {
            addFieldsForMappedKeyMapContainerPolicy(managedClass, managedAttribute, intrinsicEntity, intrinsicAttribute, isInherited, cp, table);
        }

        if (listOrderField != null) {
            FieldDefinition fieldDef = getFieldDefFromDBField(listOrderField);
            if (!table.getFields().contains(fieldDef)) {
                table.addField(fieldDef);
            }
        }
    }
 
开发者ID:jeddict,项目名称:jeddict,代码行数:33,代码来源:JPAMDefaultTableGenerator.java

示例2: buildRelationTableFields

import org.eclipse.persistence.mappings.ForeignReferenceMapping; //导入依赖的package包/类
/**
 * Build field definitions and foreign key constraints for all many-to-many
 * relation table.
 */
protected void buildRelationTableFields(ManagedClass managedClass, Attribute managedAttribute, LinkedList<Entity> intrinsicEntity, LinkedList<Attribute> intrinsicAttribute, boolean inverse, boolean isInherited, ForeignReferenceMapping mapping, TableDefinition table, List<DatabaseField> fkFields, List<DatabaseField> targetFields) {
    assert fkFields.size() > 0 && fkFields.size() == targetFields.size();

    DatabaseField fkField;
    DatabaseField targetField = null;
    List<String> fkFieldNames = new ArrayList();
    List<String> targetFieldNames = new ArrayList();

    for (int index = 0; index < fkFields.size(); index++) {
        fkField = fkFields.get(index);
        targetField = targetFields.get(index);
        fkFieldNames.add(fkField.getNameDelimited(databasePlatform));
        targetFieldNames.add(targetField.getNameDelimited(databasePlatform));

        fkField = resolveDatabaseField(fkField, targetField);
        setFieldToRelationTable(intrinsicEntity.get(0), intrinsicAttribute, managedAttribute, inverse, isInherited, fkField, table);
    }

    // add a foreign key constraint from fk field to target field
    DatabaseTable targetTable = targetField.getTable();
    TableDefinition targetTblDef = getTableDefFromDBTable(managedClass, managedAttribute, intrinsicEntity, targetTable);

    if (mapping.getDescriptor().hasTablePerClassPolicy()) {
        return;
    }
    if (mapping.getReferenceDescriptor().hasTablePerClassPolicy()
            && mapping.getReferenceDescriptor().getTablePerClassPolicy().hasChild()) {
        return;
    }
    addForeignKeyConstraint(table, targetTblDef, fkFieldNames, targetFieldNames, mapping.isCascadeOnDeleteSetOnDatabase());
}
 
开发者ID:jeddict,项目名称:jeddict,代码行数:36,代码来源:JPAMDefaultTableGenerator.java

示例3: addExtensionRelationship

import org.eclipse.persistence.mappings.ForeignReferenceMapping; //导入依赖的package包/类
/**
    * {@inheritDoc}
    */
@Override
public DataObjectRelationship addExtensionRelationship(Class<?> entityClass, String extensionPropertyName,
		Class<?> extensionEntityClass) {
	ClassDescriptor entityDescriptor = getClassDescriptor(entityClass);
	ClassDescriptor extensionEntityDescriptor = getClassDescriptor(extensionEntityClass);

	if (LOG.isDebugEnabled()) {
		LOG.debug("About to attempt to inject a 1:1 relationship on PKs between " + entityDescriptor + " and "
				+ extensionEntityDescriptor);
	}
	OneToOneMapping dm = (OneToOneMapping) entityDescriptor.newOneToOneMapping();
	dm.setAttributeName(extensionPropertyName);
	dm.setReferenceClass(extensionEntityClass);
	dm.setDescriptor(entityDescriptor);
	dm.setIsPrivateOwned(true);
	dm.setJoinFetch(ForeignReferenceMapping.OUTER_JOIN);
	dm.setCascadeAll(true);
	dm.setIsLazy(false);
	dm.dontUseIndirection();
	dm.setIsOneToOneRelationship(true);
	dm.setRequiresTransientWeavedFields(false);

       OneToOneMapping inverse = findExtensionInverse(extensionEntityDescriptor, entityClass);
       dm.setMappedBy(inverse.getAttributeName());
       for (DatabaseField sourceField : inverse.getSourceToTargetKeyFields().keySet()) {
           DatabaseField targetField = inverse.getSourceToTargetKeyFields().get(sourceField);
           // reverse them, pass the source from the inverse as our target and the target from the inverse as our source
           dm.addTargetForeignKeyField(sourceField, targetField);
       }

       dm.preInitialize(getEclipseLinkEntityManager().getDatabaseSession());
	dm.initialize(getEclipseLinkEntityManager().getDatabaseSession());
	entityDescriptor.addMapping(dm);
	entityDescriptor.getObjectBuilder().initialize(getEclipseLinkEntityManager().getDatabaseSession());

       // build the data object relationship
       ManagedTypeImpl<?> managedType = (ManagedTypeImpl<?>)getEntityManager().getMetamodel().managedType(entityClass);
       SingularAttributeImpl<?, ?> singularAttribute = new SingularAttributeLocal(managedType, dm);
       return getRelationshipMetadata(singularAttribute);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:44,代码来源:EclipseLinkJpaMetadataProviderImpl.java


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