Forget about it. Was just blind:

/**
     * If you have a reference to an Entity from another
     * UnitOfWork and want to create a reference to it in this
     * UnitOfWork, then call this method.
     *
     * @param entity the Entity to be dereferenced
     * @return an Entity from this UnitOfWork
     * @throws EntityTypeNotFoundException if no entity type could be found
     */
    <T> T get( T entity )
        throws EntityTypeNotFoundException;

Am 28.09.09 00:27, schrieb Michael Hunger:
I am working on a small demo for my jaoo tutorial.

What way of working would you suggest for returning references to
entities outside of the uow for later reference?

Right now I just return the entities and have them later reloaded when
passed into a new function (as the uow they originated from is closed).
This also limits any access to any attribute of the entity, including
identity() and type() both of which are important for the reload.

Funnily the id is equal to the toString() of the entity. So I do reload
as follows:

public void attendPresentation(Presentation presentation, Attendee
attendee) {
reload(Attendee.class, attendee).attend(reload(Presentation.class,
presentation));
}

private <T extends EntityComposite> T reload(Class<T> type, T entity) {
return uow().get(type, entity.toString());
}

what I'd like to do would be:
private <T extends EntityComposite> T reload(T entity) {
return uow().get(entity.type(), entity.identity());
}

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev


_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to