【问题标题】:Hibernate detachedcriteria for 2 joined-subclasses with the same property具有相同属性的 2 个连接子类的休眠分离标准
【发布时间】:2013-03-22 00:13:52
【问题描述】:

我有以下映射:

<class name="Animal" table="Animal" abstract="true">

    <id name="Id" column="Id" type="Guid">
       <generator class="guid.comb"/>
    </id>

    <joined-subclass name="Dog" table="Dog" lazy="false">
       <property name="Name" column="Name" type="String" length="100" not-null="true"/>
    </joined-subclass>

    <joined-subclass name="Cat" table="Cat" lazy="false">
       <property name="Name" column="Name" type="String" length="100" not-null="true"/>
    </joined-subclass>
</class>

这是我的搜索条件:

Sessoion.CreateCriteria("Animal")
    .Add(Restrictions.Eq("Name", "Pluto"))
    .List<Animal>();

由搜索条件生成的查询仅在 Dog 表中查询 Name = "Pluto"。它不会查询 Cat 表。

有人知道如何查询 Name="Pluto" 的两个表吗?

【问题讨论】:

    标签: hibernate subclass hibernate-criteria


    【解决方案1】:

    您使用的是哪个版本?我在使用 Hiberante 3.3 时遇到了同样的问题,恐怕我必须找到解决方法,因为这是一个已知的错误:

    https://hibernate.atlassian.net/browse/HHH-4829

    【讨论】:

      猜你喜欢
      • 2011-06-23
      • 1970-01-01
      • 1970-01-01
      • 2018-01-01
      • 1970-01-01
      • 2013-09-17
      • 1970-01-01
      • 2011-09-25
      • 1970-01-01
      相关资源
      最近更新 更多