當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。