2

I want to use a many-to-many relation between System & Device. I want the system to know its devices order. I've seen here that I can do it using @OrderColumn.

How can I do it using hibernate xml configuration instead of annotation?

Community
  • 1
  • 1
user1028741
  • 2,745
  • 6
  • 34
  • 68

2 Answers2

1

If you're using Hibernate you could try with

sort="unsorted|natural|comparatorClass" order-by="column_name asc|desc"

as attributes of your relatonship declaration

Matteo Baldi
  • 5,613
  • 10
  • 39
  • 51
  • The problem here is that the sorting will sort according to the sorted object itself and not the mapping. For example S1 ==> (D1,D2), S2 ==>(D2,D1) will not be possible, because the order of the devices will always be the same (according to the comparator logics..) – user1028741 Mar 27 '16 at 07:31
0

@OrderColumn is the JPA annotation introduced in JPA 2.0. This works as an additional feature if we work hibernate through JPA. There is no equivalent replacement in hibernate who work with hibernate directly.

Shaan
  • 588
  • 1
  • 4
  • 15