I m using one-to-many mapping for List using join table.
There are lot of examples available on net of this mapping using Sets but not with Lists.
Consider tables:
Table Ticket
{
ticketid int PK;
...
}
Table Attachment
{
attachmentid int PK;
...
}
Join Table:
Ticket_Attachment_Join
{
tid FK (ref to Ticket.ticketid)
aid PK FK(ref to Attachment.attachmentid)
}
Mappings:
Ticket.hbm.xml:
<hibernate-mapping>
<class name="Tickets" table="Ticket">
...
<list name="attachmentsList" table="Ticket_Attachment_Join" cascade="save-update">
<key column="ticketid"/>
<list-index column="index_col"/>
<many-to-many column="attachmentId" unique="true" class="Attachments" />
</list>
...
</class>
</hibernate-mapping>
I want to ask that in which table i should put column index_col (<list-index...>column)? In Attachment table or in join table?? Is it neccessary to put index_col for lists in the table which represents lists(Here ‘Attachment’ table).
It should be on
Ticket_Attachment_Joinas it is the table you are refering to in list mapping.And if you don’t need any indexed collections you can map that
attachmentsListusing<bag>then you don’t need that<list-index column="index_col"/>mapping at all.