Indexed lists are supporterd hibernate, but definition is important.
In the old way (XML mapping) you can work as follows:
In pojo:
private List<Child> childs;
In the XML mapping:
<list name="childs" table="yourtable" cascade="all,delete-orphan" inverse="false" lazy="false"> <key column="fk_to_parent"/> <list-index column="an_integer_column"/> <one-to-many class="Child" /> </list>
In a JPA annotation, you should use an IndexColumn
annotation as follows:
@IndexColumn(name="an_integer_column", base=0, nullable=false)
So you will have:
@Column(name="CHILD_COL") @IndexColumn(name="an_integer_column", base=0, nullable=false) private List<Child> childs;
Tell me is it good
source share