public void verify() {
   getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
   holder = (DirectEntityMapHolder) getSession().readObject(holder);
   if (!compareObjects(holder, changedHolder)) {
     throw new TestErrorException("Objects do not match reinitialize");
   }
   if (holder.getDirectToEntityMap().size() != 2) {
     throw new TestErrorException("Incorrect Number of MapEntityValues was read.");
   }
   EntityMapValue value = (EntityMapValue) holder.getDirectToEntityMap().get(new Integer(33));
   if (value.getId() != 3) {
     throw new TestErrorException("MapEntityValue was not added properly.");
   }
   value = (EntityMapValue) holder.getDirectToEntityMap().get(11);
   if (value != null) {
     throw new TestErrorException("Deleted EntityMapValue still around.");
   }
   if (mapping.isPrivateOwned()) {
     ReadObjectQuery query = new ReadObjectQuery(EntityMapValue.class);
     ExpressionBuilder values = new ExpressionBuilder();
     Expression criteria = values.get("id").equal(1);
     query.setSelectionCriteria(criteria);
     value = (EntityMapValue) getSession().executeQuery(query);
     if (value != null) {
       throw new TestErrorException("PrivateOwned EntityMapValue was not deleted.");
     }
   }
 }
  public void setup() {
    mapping =
        (ManyToManyMapping)
            getSession()
                .getProject()
                .getDescriptor(DirectEntityMapHolder.class)
                .getMappingForAttributeName("directToEntityMap");
    oldPrivateOwnedValue = mapping.isPrivateOwned();
    mapping.setIsPrivateOwned(usePrivateOwned);

    UnitOfWork uow = getSession().acquireUnitOfWork();
    holder = new DirectEntityMapHolder();
    EntityMapValue value = new EntityMapValue();
    value.setId(1);
    holder.addDirectToEntityMapItem(new Integer(11), value);

    EntityMapValue value2 = new EntityMapValue();
    value2.setId(2);
    holder.addDirectToEntityMapItem(new Integer(22), value2);
    uow.registerObject(holder);
    uow.registerObject(value);
    uow.registerObject(value2);
    uow.commit();
    Object holderForComparison = uow.readObject(holder);
    if (!compareObjects(holder, holderForComparison)) {
      throw new TestErrorException("Objects do not match after write");
    }
    getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
  }
  public void createTables(DatabaseSession session) {
    SchemaManager schemaManager = new SchemaManager(session);

    schemaManager.replaceObject(DirectEntityMapHolder.tableDefinition());
    schemaManager.replaceObject(DirectEntityMapHolder.relationTableDefinition());
    schemaManager.replaceObject(DirectEntity1MMapHolder.tableDefinition());
    schemaManager.replaceObject(EntityMapValue.tableDefinition());
    schemaManager.replaceObject(AggregateEntityMapHolder.tableDefinition());
    schemaManager.replaceObject(AggregateEntityMapHolder.relationTableDefinition());
    schemaManager.replaceObject(EntityEntityMapHolder.tableDefinition());
    schemaManager.replaceObject(EntityEntityMapHolder.relationTableDefinition());
    schemaManager.replaceObject(EntityMapKey.tableDefinition());
    schemaManager.replaceObject(DirectDirectMapHolder.tableDefinition());
    schemaManager.replaceObject(DirectDirectMapHolder.relationTableDefinition());
    schemaManager.replaceObject(AggregateDirectMapHolder.tableDefinition());
    schemaManager.replaceObject(AggregateDirectMapHolder.relationTableDefinition());
    schemaManager.replaceObject(EntityDirectMapHolder.tableDefinition());
    schemaManager.replaceObject(EntityDirectMapHolder.relationTableDefinition());
    schemaManager.replaceObject(AggregateAggregateMapHolder.tableDefinition());
    schemaManager.replaceObject(AggregateAggregateMapHolder.relationTableDefinition());
    schemaManager.replaceObject(DirectAggregateMapHolder.tableDefinition());
    schemaManager.replaceObject(DirectAggregateMapHolder.relationTableDefinition());
    schemaManager.replaceObject(EntityAggregateMapHolder.tableDefinition());
    schemaManager.replaceObject(EntityAggregateMapHolder.relationTableDefinition());
    schemaManager.replaceObject(DEOTMMapValue.tableDefinition());
    schemaManager.replaceObject(AggregateEntity1MMapHolder.tableDefinition());
    schemaManager.replaceObject(AEOTMMapValue.tableDefinition());
    schemaManager.replaceObject(EntityEntity1MMapHolder.tableDefinition());
    schemaManager.replaceObject(EEOTMMapValue.tableDefinition());
    schemaManager.replaceObject(DirectEntityU1MMapHolder.tableDefinition());
    schemaManager.replaceObject(AggregateEntityU1MMapHolder.tableDefinition());
    schemaManager.replaceObject(EntityEntityU1MMapHolder.tableDefinition());
    schemaManager.createSequences();
  }
 public void reset() {
   UnitOfWork uow = getSession().acquireUnitOfWork();
   Iterator j = holder.getDirectToEntityMap().keySet().iterator();
   while (j.hasNext()) {
     uow.deleteObject(holder.getDirectToEntityMap().get(j.next()));
   }
   uow.deleteObject(holder);
   uow.commit();
   mapping.setIsPrivateOwned(oldPrivateOwnedValue);
 }
  public void test() {
    UnitOfWork uow = getSession().acquireUnitOfWork();
    changedHolder = (DirectEntityMapHolder) uow.readObject(holder);
    EntityMapValue value = new EntityMapValue();
    value.setId(3);
    changedHolder.addDirectToEntityMapItem(new Integer(33), value);

    changedHolder.getDirectToEntityMap().remove(new Integer(11));
    uow.commit();
    Object holderForComparison = uow.readObject(holder);
    if (!compareObjects(changedHolder, holderForComparison)) {
      throw new TestErrorException("Objects do not match after write");
    }
  }