list-index hibernate?

时间:2010-06-10 08:47:26

标签: hibernate

我对列表索引类型有点混淆,我的映射文件如下所示

<list name="transactionItems" cascade="save-update,delete-orphan" lazy="false"> <key column="TRANSACTION_ID" /> <list-index column="IDX" /> <one-to-many class="TransactionItem" /> </list>

每当hibernate加载一个映射对象时,它通过异常 null索引列进行收集:transactionItems 请告诉我这里可能出现什么问题。你可以对list-index进行一些改动吗?

2 个答案:

答案 0 :(得分:1)

我认为它应该是多对一的,但这可能不是你获得例外的原因....

答案 1 :(得分:0)

请参考以下内容确保您的代码:

<list name="ListCollectionName" cascade="save-update,delete-orphan"
   lazy="false">
   <key column="FKCOLUMN" />
   <list-index column="IDX" />
<!-- column IDX should be created in your detail table you can also use any other column here and providing base if necessary. base 1 = the list will fill from index 1 byDefault it is 0 -->
   <one-to-many class="FullyQualifiedNameOFDetailTable" />
  </list>