protected void setup() { descriptor = ((DatabaseSession) getSession()).getDescriptor(Actor.class); mapping = (VariableOneToOneMapping) descriptor.getMappingForAttributeName("program"); sourceField = new DatabaseField("ACTOR.PROGRAM_ID"); targetQueryKeyName = (String) mapping.getSourceToTargetQueryKeyNames().get(sourceField); mapping.addForeignQueryKeyName("ACTOR.PROGRAM_ID", "name2"); mapping.getForeignKeyFields().removeElement(sourceField); actor = Actor.example4(); databaseRow = new DatabaseRecord(); if (testMode == 0) { // nothing extra needed } else if (testMode == 1) { ObjectChangeSet changeSet = new ObjectChangeSet(new Vector(), descriptor, actor, new UnitOfWorkChangeSet(), true); changeRecord = new ObjectReferenceChangeRecord(changeSet); changeRecord.setNewValue(changeSet); } else if (testMode == 2) { deleteObjectQuery = new DeleteObjectQuery(actor); deleteObjectQuery.setSession((AbstractSession) getSession()); } expectedException = DescriptorException.variableOneToOneMappingIsNotDefinedProperly( mapping, descriptor, targetQueryKeyName); }
/** * PUBLIC: A foreign key from the source table and abstract query key from the interface * descriptor are added to the mapping. This method is used if foreign key is not composite. */ public void setForeignQueryKeyName(String sourceForeignKeyFieldName, String targetQueryKeyName) { addForeignQueryKeyName(sourceForeignKeyFieldName, targetQueryKeyName); }
/** * PUBLIC: A foreign key from the source table and abstract query key from the interface * descriptor are added to the mapping. This method is used if there are multiple foreign keys. */ public void addForeignQueryKeyName(String sourceForeignKeyFieldName, String targetQueryKeyName) { addForeignQueryKeyName(new DatabaseField(sourceForeignKeyFieldName), targetQueryKeyName); }
public void reset() { mapping.addForeignQueryKeyName("ACTOR.PROGRAM_ID", targetQueryKeyName); mapping.getForeignKeyFields().removeElement(sourceField); }