Regardless if my entity is in the cache or not, is there a way to force a post-initialization when retrieving an entity ?
I usually don't need to do that but I have a special use-case for that.
In Breeze, the automatic initialization (i.e. calling a custom initializer) only happens when creating an entity. It won't be called when a query returns an entity that already exists in the cache. In that case, the entity data from the server is merged into the existing client entity, but the initializer is not called.
You can do your own entity processing when the query returns:
em.executeQuery(query).then(function(data) {
entities = data.results;
entities.forEach(function(entity) {
// post-initialize the entity
// (it has already been merged into the cache)
});
return entities;
});