Search in sources :

Example 1 with Actor

use of org.eclipse.persistence.testing.models.interfaces.Actor in project eclipselink by eclipse-ee4j.

the class VariableOneToOneMappingIsNotDefinedProperlyTest method setup.

@Override
protected void setup() {
    descriptor = 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);
}
Also used : ObjectReferenceChangeRecord(org.eclipse.persistence.internal.sessions.ObjectReferenceChangeRecord) DatabaseRecord(org.eclipse.persistence.sessions.DatabaseRecord) Actor(org.eclipse.persistence.testing.models.interfaces.Actor) DatabaseField(org.eclipse.persistence.internal.helper.DatabaseField) UnitOfWorkChangeSet(org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet) ObjectChangeSet(org.eclipse.persistence.internal.sessions.ObjectChangeSet) DeleteObjectQuery(org.eclipse.persistence.queries.DeleteObjectQuery) Vector(java.util.Vector)

Aggregations

Vector (java.util.Vector)1 DatabaseField (org.eclipse.persistence.internal.helper.DatabaseField)1 ObjectChangeSet (org.eclipse.persistence.internal.sessions.ObjectChangeSet)1 ObjectReferenceChangeRecord (org.eclipse.persistence.internal.sessions.ObjectReferenceChangeRecord)1 UnitOfWorkChangeSet (org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet)1 DeleteObjectQuery (org.eclipse.persistence.queries.DeleteObjectQuery)1 DatabaseRecord (org.eclipse.persistence.sessions.DatabaseRecord)1 Actor (org.eclipse.persistence.testing.models.interfaces.Actor)1