public void setup() { mapping = (ManyToManyMapping) getSession() .getProject() .getDescriptor(AggregateEntityMapHolder.class) .getMappingForAttributeName("aggregateToEntityMap"); oldFetchJoinValue = mapping.getJoinFetch(); mapping.setJoinFetch(fetchJoinRelationship); getSession() .getProject() .getDescriptor(AggregateEntityMapHolder.class) .reInitializeJoinedAttributes(); UnitOfWork uow = getSession().acquireUnitOfWork(); AggregateEntityMapHolder holder = new AggregateEntityMapHolder(); EntityMapValue value = new EntityMapValue(); value.setId(1); AggregateMapKey key = new AggregateMapKey(); key.setKey(11); holder.addAggregateToEntityMapItem(key, value); EntityMapValue value2 = new EntityMapValue(); value2.setId(2); key = new AggregateMapKey(); key.setKey(22); holder.addAggregateToEntityMapItem(key, value2); uow.registerObject(holder); uow.registerObject(value); uow.registerObject(value2); uow.commit(); holderExp = (new ExpressionBuilder()).get("id").equal(holder.getId()); getSession().getIdentityMapAccessor().initializeAllIdentityMaps(); }