added a comment - - edited
I think that it must be possible to have two keys ordering : the order isn't obligatory reversible.
For exemple with user and group :
- You can order groups for one user : with preference by exemple, or importance.
- And with a different order, users for a group : rank by example.
And maybe more, if you decide to add multi-order : an user show group by his rank in it, if his rank is identical, the order is make by love preference, and after by the importance given by the user (not necessary a number, if we imagine filter on them).
So a default order can be choice with parametized fields and could be :
@ManyToMany(targetEntity="Group")
...
@JoinFields ( rank: { type: int} , preference:{type:int}, importance:{type: string, length: 40} )
@OrderByJoinFields({"rank" = "ASC", "preference"="ASC", "importance"="ASC" } )
In this case the order must be optional and would be clean if another order appears in the same scope (DQL...). And manytomany became virtual entities act as other entities except they don't appears permetting in the same time a better conception.
So if the solution take in DDC-181 will become the only solution. This would a good idea to document this. Because, this seems to me a very important point.
My last point is even an unique ordering field created in the join table will be a big and usefull improvement.
Thank a lot for your beautiful work.
Roman, I'd like to do this one as I have currently a use case for this. Do you have any idea of how to do this? What I'm wondering is whether it is possible to implement this without user intervention. (This would simply mean "store the entities as they were added"). But this would need another column in DB that we'd have to add within oneToMany / manyToMany relationships, but in this case one could save a serialized array holding "entityId => position" key / value pairs.
Afterwards, one could easily rebuild / reorder the collection via $collection->set($entity, $order[$entity->identifier]);
If you've got another thought about this, please don't hesitate to point me into the right direction!