About Question enthuware.oce-jpad.v6.2.426 :
Posted: Tue Sep 22, 2015 7:59 am
Hi.
Actually it's not completely clear from the question what actually we want to achieve.
The question says:
"You have a ManyToMany bidirectional relationship between Student and Course entities. You want the order of Students who register for a Course to be preserved but you do not want any additional persistent field in the entities to support this."
Let's summarize it:
1) We have @ManyToMany
2) We want to preserve the order of elements but we don't want to create a new persistence fields in Entity.
I chose the answer "Use @OrderBy annotation on Student collection field in Course entity" and failed.
The explanation of the question says that we can't use @OrderBy because we don't want to specify any persistence column in it
("orderBy is used when you have a persistent field in the entity of the collection by which you want to order. ")
But what if we didn't specify any column in @OrderBy at all. In this case the persistence provider will use identity as a sorting criteria.
I see that it's quite legal answer to the questions because we preserved order and didn't create new persistence columns, isn't it?
Thanks,
Igor.
Actually it's not completely clear from the question what actually we want to achieve.
The question says:
"You have a ManyToMany bidirectional relationship between Student and Course entities. You want the order of Students who register for a Course to be preserved but you do not want any additional persistent field in the entities to support this."
Let's summarize it:
1) We have @ManyToMany
2) We want to preserve the order of elements but we don't want to create a new persistence fields in Entity.
I chose the answer "Use @OrderBy annotation on Student collection field in Course entity" and failed.
The explanation of the question says that we can't use @OrderBy because we don't want to specify any persistence column in it
("orderBy is used when you have a persistent field in the entity of the collection by which you want to order. ")
But what if we didn't specify any column in @OrderBy at all. In this case the persistence provider will use identity as a sorting criteria.
I see that it's quite legal answer to the questions because we preserved order and didn't create new persistence columns, isn't it?
Thanks,
Igor.