我在 Hibernate 3 中使用 Java。
我有一个sql如下:
select sd3.id as id_3, sd2.id as id_2, sd1.id as id_1, od.id as id_0 from developer as sd3
left outer join developer as sd2 on sd3.sr_developer_id = sd2.id
left outer join developer as sd1 on sd2.sr_developer_id = sd1.id
left outer join developer as od on sd1.sr_developer_id = od.id
where sd3.id = 812
这是一个自加入的情况。
表结构如下所示:
开发商
id | sr_developer_id
---------------------
812 | 463
463 | 8
8 | NULL
上述查询的输出是:
id_3 | id_2 | id_1 | id_0
--------------------------
812 | 463 | 8 | NULL
现在我想在 HQL 或条件中转换此查询。谁能帮我?
编辑 :-
开发者.java
private long id;
private long srDeveloperID;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getSrDeveloperID() {
return srDeveloperID;
}
public void setSrDeveloper(long srDeveloperID) {
this.srDeveloperID = srDeveloperID;
}
开发者.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping >
<class name="com.beans.Developer" table="developer">
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<property name="srDeveloperID" column="sr_developer_id" type="long"></property>
</class>
</hibernate-mapping>