On 2010-12-08 00.03, Ronnie Nessa wrote:
In my application I have a re-indexer service that under certain
conditions reindexes the entire database when the application is
started ( I think I borrowed some of the code from streamflow). Also I
have a service that when activated conditionally bootstraps some
initial data. My problem is that it is important that the re-indexer
service runs before the bootstrap service, but as I see it they are
not really dependent on each other, so making them dependent would be
weird I think. Maybe I'm attacking this from the wrong angle though.
Have any of you solved a similar problem in a different way?
The trick is to let your initial data bootstrap work with known Entity
id's, rather than doing queries. In my case I have a known Users entity,
with a given id, that I check for:
try
{
// Check if users entity exists
users = uow.get( UsersEntity.class, UsersEntity.USERS_ID );
} catch (NoSuchEntityException e)
{
// Create bootstrap data
users = uow.newEntity( UsersEntity.class, UsersEntity.USERS_ID );
}
/Rickard
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev