HQL仅使用' where子句中第一个孩子的财产

时间:2016-09-05 13:07:39

标签: java sql-server hibernate orm hql

我正在使用@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)

父类是一个抽象类,有两个子类。设备和系统

  public abstract class Parent {

    @Id
    @Column(name = "idParent")
    protected int parentId;

    abstract public String getManufacturer();

    abstract public void setManufacturer(String manufacturer);

    abstract public Date getUpdated();

    abstract public void setUpdated(Date updated);
    }

    public class Device extends Parent {

    @Column(name = "Device_Manufacturer")
    private String manufacturer;

    public String getManufacturer() {
        return this.manufacturer;
    }

    public void setManufacturer(String Manufacturer) {
        this.manufacturer = manufacturer;
    }

    @Column(name = "Device_Last_Edit")
    private Date updated;

    public Date getUpdated() {
        return this.updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;

    }
    }

    public class System extends Parent {

    @Column(name = "System_Manufacturer")
    private String manufacturer;

    public Date getUpdated() {
        return this.updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;

    }

    @Column(name = "System_Last_Edit")
    private Date updated;

    public Date getUpdated() {
            return this.updated;
        }

        public void setUpdated(Date updated) {
            this.updated = updated;

        }

    }

当我使用where子句

查询时
  

Parent.manufacturer =' ABC'

,HQL生成的查询通过执行System和Device的联合来查询两个子项。

但它将where子句应用于

  

Device_Manufacturer

只有

而不是

  

System.Manufacturer

我尝试使用

  

类型(父级)=系统

在where子句中但仍然是HQL生成相同的SQL

0 个答案:

没有答案