Hello!
I've read in the
Java Persistence with Hibernate book that Hibernate expects a
HashSet implementation for a
Set interface, and a
TreeSet implementation for a
SortedSet interface. I created a type named AulaReserva and defined a natural order for it and mapped it this way in an entity class:
Code:
private Set<AulaReserva> fAulasReserva = new TreeSet<AulaReserva>();
@OneToMany(mappedBy = "dataReserva",
cascade = {CascadeType.PERSIST, CascadeType.REMOVE})
public Set<AulaReserva> getAulasReserva()
{
return fAulasReserva;
}
public void setAulasReserva(Set<AulaReserva> aulasReserva)
{
fAulasReserva = aulasReserva;
}
Notice that I'm using
Set and not
SortedSet for the property. So, my question is this: will Hibernate replace my
TreeSet implementation by a
HashSet implementation? If so, this would be disastrous for me, as I need the collection to be sorted using its natural order. Do I really have to use the
SortedSet in this case?
Thank you.
Marcos