有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

映射到“sql select”表的java Hibernate集

你好

我有一个hibernate映射,它是这样的

<class name="Person">
  <id name="id" type="long" column="person_id" unsaved-value="null">
        <generator class="sequence">
            <param name="sequence">person_id_seq</param>
        </generator>
  </id>
  ...
  <set name="thinCollection" table="(select person_id, person_property from some_other_table where another_property = 'something')" fetch="subselect" lazy="false">
    <key column="person_id"/>
    <element column="person_property" type="long"/>
  </set>
  ...
</class>

现在我的问题是,当Person对象被刷新时,它试图对Person#thinCollection执行一个Collection Remove操作,该操作失败,因为它试图执行delete from (select person_id, person_property from some_other_table where another_property = 'something')

因此,与此一致,我如何阻止Hibernate执行此类操作(以及更新和插入)

谢谢


共 (0) 个答案