/** * INTERNAL: * Return all the target relation key fields associated with the mapping. */ public Vector<DatabaseField> getTargetRelationKeyFields() { return this.mechanism.getTargetRelationKeyFields(); }
/** * INTERNAL: * Return all the target relation key fields associated with the mapping. */ public Vector<DatabaseField> getTargetRelationKeyFields() { return this.mechanism.getTargetRelationKeyFields(); }
/** * INTERNAL: * Return all the target relation key fields associated with the mapping. */ public Vector<DatabaseField> getTargetRelationKeyFields() { return this.mechanism.getTargetRelationKeyFields(); }
/** * PUBLIC: * Return the target relation key field names associated with the mapping. * These are in-order with the targetKeyFieldNames. */ public Vector getTargetRelationKeyFieldNames() { Vector fieldNames = new Vector(getTargetRelationKeyFields().size()); for (Enumeration fieldsEnum = getTargetRelationKeyFields().elements(); fieldsEnum.hasMoreElements();) { fieldNames.addElement(((DatabaseField)fieldsEnum.nextElement()).getQualifiedName()); } return fieldNames; }
/** * PUBLIC: * Add the fields in the intermediate table that corresponds to the primary * key in the target table. This method is used if the keys are composite. */ public void addTargetRelationKeyField(DatabaseField targetRelationKeyField, DatabaseField targetPrimaryKeyField) { getTargetRelationKeyFields().addElement(targetRelationKeyField); getTargetKeyFields().addElement(targetPrimaryKeyField); }
/** * PUBLIC: * Return the target relation key field names associated with the mapping. * These are in-order with the targetKeyFieldNames. */ public Vector getTargetRelationKeyFieldNames() { Vector fieldNames = new Vector(getTargetRelationKeyFields().size()); for (Enumeration fieldsEnum = getTargetRelationKeyFields().elements(); fieldsEnum.hasMoreElements();) { fieldNames.addElement(((DatabaseField)fieldsEnum.nextElement()).getQualifiedName()); } return fieldNames; }
/** * PUBLIC: * Return the target relation key field names associated with the mapping. * These are in-order with the targetKeyFieldNames. */ public Vector getTargetRelationKeyFieldNames() { Vector fieldNames = new Vector(getTargetRelationKeyFields().size()); for (Enumeration fieldsEnum = getTargetRelationKeyFields().elements(); fieldsEnum.hasMoreElements();) { fieldNames.addElement(((DatabaseField)fieldsEnum.nextElement()).getQualifiedName()); } return fieldNames; }
/** * PUBLIC: * Set the target key field in the relation table. * This is the name of the foreign key in the relation table to the target's primary key field. * This method is used if the target's primary key is a singleton only. */ public void setTargetRelationKeyFieldName(String targetRelationKeyFieldName) { getTargetRelationKeyFields().addElement(new DatabaseField(targetRelationKeyFieldName)); }
/** * PUBLIC: * Set the target key field in the relation table. * This is the name of the foreign key in the relation table to the target's primary key field. * This method is used if the target's primary key is a singleton only. */ public void setTargetRelationKeyFieldName(String targetRelationKeyFieldName) { getTargetRelationKeyFields().addElement(new DatabaseField(targetRelationKeyFieldName)); }
/** * PUBLIC: * Add the fields in the intermediate table that corresponds to the primary * key in the target table. This method is used if the keys are composite. */ public void addTargetRelationKeyField(DatabaseField targetRelationKeyField, DatabaseField targetPrimaryKeyField) { getTargetRelationKeyFields().addElement(targetRelationKeyField); getTargetKeyFields().addElement(targetPrimaryKeyField); }
/** * PUBLIC: * Add the fields in the intermediate table that corresponds to the primary * key in the target table. This method is used if the keys are composite. */ public void addTargetRelationKeyField(DatabaseField targetRelationKeyField, DatabaseField targetPrimaryKeyField) { getTargetRelationKeyFields().addElement(targetRelationKeyField); getTargetKeyFields().addElement(targetPrimaryKeyField); }
/** * PUBLIC: * Set the target key field in the relation table. * This is the name of the foreign key in the relation table to the target's primary key field. * This method is used if the target's primary key is a singleton only. */ public void setTargetRelationKeyFieldName(String targetRelationKeyFieldName) { getTargetRelationKeyFields().addElement(new DatabaseField(targetRelationKeyFieldName)); }
/** * INTERNAL: * All the target relation key field names are converted to DatabaseField and stored. */ protected void initializeTargetRelationKeys(AbstractSession session, ForeignReferenceMapping mapping) { if (getTargetRelationKeyFields().size() == 0) { throw DescriptorException.noTargetRelationKeysSpecified(mapping); } for (Enumeration targetEnum = getTargetRelationKeyFields().elements(); targetEnum.hasMoreElements();) { DatabaseField field = (DatabaseField)targetEnum.nextElement(); if (field.hasTableName() && (!(field.getTableName().equals(getRelationTable().getName())))) { throw DescriptorException.relationKeyFieldNotProperlySpecified(field, mapping); } field.setTable(getRelationTable()); } }
/** * INTERNAL: * All the target relation key field names are converted to DatabaseField and stored. */ protected void initializeTargetRelationKeys(ForeignReferenceMapping mapping) { if (getTargetRelationKeyFields().size() == 0) { throw DescriptorException.noTargetRelationKeysSpecified(mapping); } for (Enumeration targetEnum = getTargetRelationKeyFields().elements(); targetEnum.hasMoreElements();) { DatabaseField field = (DatabaseField)targetEnum.nextElement(); // Update the fields table first if the mapping is from a table per tenant entity. ClassDescriptor referenceDescriptor = mapping.getReferenceDescriptor(); if (referenceDescriptor.hasTablePerMultitenantPolicy()) { field.setTable(((TablePerMultitenantPolicy) referenceDescriptor.getMultitenantPolicy()).getTable(field.getTable())); } if (field.hasTableName() && (!(field.getTableName().equals(getRelationTable().getName())))) { throw DescriptorException.relationKeyFieldNotProperlySpecified(field, mapping); } field.setTable(getRelationTable()); } }
/** * INTERNAL: * All the target relation key field names are converted to DatabaseField and stored. */ protected void initializeTargetRelationKeys(ForeignReferenceMapping mapping) { if (getTargetRelationKeyFields().size() == 0) { throw DescriptorException.noTargetRelationKeysSpecified(mapping); } for (Enumeration targetEnum = getTargetRelationKeyFields().elements(); targetEnum.hasMoreElements();) { DatabaseField field = (DatabaseField)targetEnum.nextElement(); // Update the fields table first if the mapping is from a table per tenant entity. ClassDescriptor referenceDescriptor = mapping.getReferenceDescriptor(); if (referenceDescriptor.hasTablePerMultitenantPolicy()) { field.setTable(((TablePerMultitenantPolicy) referenceDescriptor.getMultitenantPolicy()).getTable(field.getTable())); } if (field.hasTableName() && (!(field.getTableName().equals(getRelationTable().getName())))) { throw DescriptorException.relationKeyFieldNotProperlySpecified(field, mapping); } field.setTable(getRelationTable()); } }
/** * INTERNAL: * The mapping clones itself to create deep copy. */ public Object clone() { RelationTableMechanism clone; try { clone = (RelationTableMechanism)super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(); } clone.setTargetKeyFields(cloneFields(getTargetKeyFields())); clone.setSourceKeyFields(cloneFields(getSourceKeyFields())); clone.setTargetRelationKeyFields(cloneFields(getTargetRelationKeyFields())); clone.setSourceRelationKeyFields(cloneFields(getSourceRelationKeyFields())); clone.setInsertQuery((DataModifyQuery) insertQuery.clone()); clone.setDeleteQuery((DataModifyQuery) deleteQuery.clone()); if(lockRelationTableQuery != null) { clone.lockRelationTableQuery = (DirectReadQuery)lockRelationTableQuery.clone(); } return clone; }
/** * Build relation table definitions for all many-to-many relationships in a EclipseLink descriptor. */ protected void buildRelationTableDefinition(ForeignReferenceMapping mapping, RelationTableMechanism relationTableMechanism, DatabaseField listOrderField, ContainerPolicy cp) { //first create relation table TableDefinition table = getTableDefFromDBTable(relationTableMechanism.getRelationTable()); //add source foreign key fields into the relation table List<DatabaseField> srcFkFields = relationTableMechanism.getSourceRelationKeyFields(); List<DatabaseField> srcKeyFields = relationTableMechanism.getSourceKeyFields(); buildRelationTableFields(mapping, table, srcFkFields, srcKeyFields); //add target foreign key fields into the relation table List<DatabaseField> targFkFields = relationTableMechanism.getTargetRelationKeyFields(); List<DatabaseField> targKeyFields = relationTableMechanism.getTargetKeyFields(); buildRelationTableFields(mapping, table, targFkFields, targKeyFields); if (cp != null){ addFieldsForMappedKeyMapContainerPolicy(cp, table); } if (listOrderField != null) { FieldDefinition fieldDef = getFieldDefFromDBField(listOrderField); if (!table.getFields().contains(fieldDef)) { table.addField(fieldDef); } } }
/** * INTERNAL: * The mapping clones itself to create deep copy. */ public Object clone() { RelationTableMechanism clone; try { clone = (RelationTableMechanism)super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(); } clone.setTargetKeyFields(cloneFields(getTargetKeyFields())); clone.setSourceKeyFields(cloneFields(getSourceKeyFields())); clone.setTargetRelationKeyFields(cloneFields(getTargetRelationKeyFields())); clone.setSourceRelationKeyFields(cloneFields(getSourceRelationKeyFields())); clone.setInsertQuery((DataModifyQuery) insertQuery.clone()); clone.setDeleteQuery((DataModifyQuery) deleteQuery.clone()); if(lockRelationTableQuery != null) { clone.lockRelationTableQuery = (DirectReadQuery)lockRelationTableQuery.clone(); } return clone; }
/** * INTERNAL: * The mapping clones itself to create deep copy. */ public Object clone() { RelationTableMechanism clone; try { clone = (RelationTableMechanism)super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(); } clone.setTargetKeyFields(cloneFields(getTargetKeyFields())); clone.setSourceKeyFields(cloneFields(getSourceKeyFields())); clone.setTargetRelationKeyFields(cloneFields(getTargetRelationKeyFields())); clone.setSourceRelationKeyFields(cloneFields(getSourceRelationKeyFields())); clone.setInsertQuery((DataModifyQuery) insertQuery.clone()); clone.setDeleteQuery((DataModifyQuery) deleteQuery.clone()); if(lockRelationTableQuery != null) { clone.lockRelationTableQuery = (DirectReadQuery)lockRelationTableQuery.clone(); } return clone; }
/** * Build relation table definitions for all many-to-many relationships in a EclipseLink descriptor. */ private void buildRelationTableDefinition(RelationTableMechanism relationTableMechanism, DatabaseField listOrderField, ContainerPolicy cp) { //first create relation table TableDefinition tblDef = getTableDefFromDBTable(relationTableMechanism.getRelationTable()); //add source foreign key fields into the relation table Vector srcFkFields = relationTableMechanism.getSourceRelationKeyFields(); Vector srcKeyFields = relationTableMechanism.getSourceKeyFields(); buildRelationTableFields(tblDef, srcFkFields, srcKeyFields); //add target foreign key fields into the relation table Vector targFkFields = relationTableMechanism.getTargetRelationKeyFields(); Vector targKeyFields = relationTableMechanism.getTargetKeyFields(); buildRelationTableFields(tblDef, targFkFields, targKeyFields); if (cp != null){ addFieldsForMappedKeyMapContainerPolicy(cp, tblDef); } if(listOrderField != null) { tblDef.addField(getFieldDefFromDBField(listOrderField, false)); } }