so finally end with something that I am satisfy with, will not explain details as it is internally very similar to the previous post :
one native array for all components :
an entity array and a fast index acces Hastable
Hastable <Integer,Integer> entityNativeIndex;
the new point is that I added an EntityManager that is responsible of adding new entity and/or components, every component added to an entity is added by the entitymanager every new entity is added by the entity manager, this enable good integrity and nivce looking code and good eficiency,
code looks like :
and still able to threat componnents as blocks for systems or DB saving with cross access to other components of the current entity
the EntityManager is responsible to maintain coherence between component & entity, all storage (component/entity) is made in native arrays, the Entity class is only usefull to enable cross component access and fast entity loading (in DB it give for an entity all components it use => direct DB modifcation are then inded not alowed to keep DB integrity).
I personally tend to optimise entity management in each program i make. I find that I always do it different.
I understand what you mean and have similar feeling than you, it would have been a lot easier (faster) to make something more specific but I really wanted to find something more generic to let 'more open ways for the futur'
I am curious to know, what sort of game/application you were developing this for?
this is for an online game : MMO and we can say in a certain manner MMORPG (even if there wont be any magic, potion, dwarf or such...)
EDIT: the slower part is to get an entity by its ID (use of the hashtable) but it should not be used a lot, all other acces are direct acces : all component keep a direct link to its entity and all entity keep a direct link to each of its components