Add new object as first value of associated objects

0
My domain model has Many-to-Many relation between Two entities. I want to know if there is a way to add new object of entity2 as the first value to entity1 through association. After adding this value if I try to retrieve entity2 objects from entity1 using association, I should get latest added at top, 2nd object as the one added before latest and so on… One way to achieve is to iterate the loop and create new objects and create the association. Delete old list after the loop. This is taking sometime so I am looking if there is a better way to implement this.
asked
1 answers
1

A many to many association can be set to a single object as you are doing with the loop I assume, but you can also set the association with the complete new list. This will replace the associations to the old list and with some sorting on the new list I think you can achieve the same results.

answered