Den 27. okt. 2010 kl. 04.21 skrev Rickard Öberg:

> On 2010-10-26 22.11, Ronnie Nessa wrote:
>> 1. Is using unitOfWork.create(MyEntity.class, "myReadableIdentifier") a
>> good solution to support my use case?
> 
> Yes, and I do the exact same thing: on startup I check whether some bootstrap 
> entities are available (in EventSourcing all events have to come from 
> entities, so bootstrapping the first one is mandatory), and if not I use the 
> uow.newEntity(MyEntity.class,SOMECONSTANTID) method.
> 
> In fact, I ALWAYS use the newEntity(class,id) method, since entities are 
> always created as a response to an event, and the event MUST have the id of 
> the new entity. Otherwise replay of events wouldn't create the same state.

Great, then I know that I´m on the right track:)

> 
>> 2. Is there an easy way to change the identity of an entity that already
>> exist in the EntityStore?
> 
> Not really, no. You can always create a copy of it and store it, but the 
> references to it is the main issue. I have a few usecases of "replace A with 
> B" and "merge A into B" and what I do is to basically query for all known 
> references to A and set them to B in code.

Yes, it´s the references i figured was the hard part as well. Maybe that is 
what I have to do combined with the Service as you pointed out under. 

> 
>> 3. How do you use the MigrationOperation to update entities when you
>> don´t know the id of the entities until runtime? Specifically; How do
>> you get access to application components from an instance of a
>> MigrationOperation?
> 
> Migration is run before the application is really started, in a sense, so 
> you're only allowed to work on state. If you need anything else, then I 
> recommend doing a service with .instantiateOnStartup(), and implement the 
> more complex logic in the activate() method.
> 
> /Rickard

That might be the way to go. Thanks. 




Best regards
Webstep AS
 
RONNIE NESSA  |  Senior Consultant
Mob : +47 970 69 512  | [email protected]
www.webstep.no





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

Reply via email to