我有4个表,各对应着主外键关系,请看映射文件:
我想做这样的sql查询:select * from hr_branch_info where hbi_n_prior=? and hbi_v_name=?
请把它转写成HQL语句,我刚接触hibernate不大会。如能给解释一下就更好了。
<hibernate-mapping>
<class name="com.pojo.HrBranchInfo" table="hr_branch_info" schema="public">
<id name="hbiNId" type="java.lang.Integer">
<column name="hbi_n_id" />
<generator class="sequence" />
</id>
<many-to-one name="hrEmpBase" class="com.pojo.HrEmpBase" fetch="select">
<column name="hbi_n_operator" not-null="false"/>
</many-to-one>
<many-to-one name="hrBranchInfo" class="com.pojo.HrBranchInfo" fetch="select">
<column name="hbi_n_prior" not-null="false" />
</many-to-one>
<property name="hbiVName" type="java.lang.String">
<column name="hbi_v_name" length="40" not-null="true" />
</property>
<property name="hbiCState" type="java.lang.String">
<column name="hbi_c_state" length="1" not-null="true" />
</property>
<property name="hbiVDesc" type="java.lang.String">
<column name="hbi_v_desc" length="200" />
</property>
<property name="hbiCTime" type="java.lang.String">
<column name="hbi_c_time" length="14" />
</property>
<property name="hbiNSortindex" type="java.lang.String">
<column name="hbi_n_sortindex" length="10" />
</property>
<property name="hbiVTemp1" type="java.lang.String">
<column name="hbi_v_temp1" length="100" />
</property>
<property name="hbiVTemp2" type="java.lang.String">
<column name="hbi_v_temp2" length="100" />
</property>
<property name="hbiVTemp3" type="java.lang.String">
<column name="hbi_v_temp3" length="100" />
</property>
<set name="hrRelationBranduties" inverse="true">
<key>
<column name="hbi_n_id" not-null="true" />
</key>
<one-to-many class="com.pojo.HrRelationBranduty" />
</set>
<set name="hrBranchInfos" inverse="true">
<key>
<column name="hbi_n_prior" not-null="true" />
</key>
<one-to-many class="com.pojo.HrBranchInfo" />
</set>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="com.pojo.HrRelationBranduty" table="hr_relation_branduty" schema="public">
<id name="hrbNId" type="java.lang.Integer">
<column name="hrb_n_id" />
<generator class="sequence" />
</id>
<many-to-one name="hrDutyInfo" class="com.pojo.HrDutyInfo" fetch="select">
<column name="hdi_n_id" not-null="true" />
</many-to-one>
<many-to-one name="hrBranchInfo" class="com.pojo.HrBranchInfo" fetch="select">
<column name="hbi_n_id" not-null="true" />
</many-to-one>
<property name="hrbCState" type="java.lang.String">
<column name="hrb_c_state" length="1" not-null="true" />
</property>
<property name="hrbVTemp1" type="java.lang.String">
<column name="hrb_v_temp1" length="100" />
</property>
<property name="hrbVTemp2" type="java.lang.String">
<column name="hrb_v_temp2" length="100" />
</property>
<property name="hrbVTemp3" type="java.lang.String">
<column name="hrb_v_temp3" length="100" />
</property>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="com.pojo.HrEmpBase" table="hr_emp_base" schema="public">
<id name="hebNId" type="java.lang.Integer">
<column name="heb_n_id" />
<generator class="sequence" />
</id>
<many-to-one name="hrDutyInfo" class="com.pojo.HrDutyInfo" fetch="select">
<column name="hdi_n_id" not-null="true" />
</many-to-one>
<property name="hebVName" type="java.lang.String">
<column name="heb_v_name" length="40" not-null="true" />
</property>
<property name="hebVUsedname" type="java.lang.String">
<column name="heb_v_usedname" length="40" />
</property>
<property name="hebVEngname" type="java.lang.String">
<column name="heb_v_engname" length="40" />
</property>
<property name="hebCSex" type="java.lang.String">
<column name="heb_c_sex" length="1" />
</property>
<property name="hebCBir" type="java.lang.String">
<column name="heb_c_bir" length="8" />
</property>
<property name="hebCMobile" type="java.lang.String">
<column name="heb_c_mobile" length="20" />
</property>
<property name="hebCHometel" type="java.lang.String">
<column name="heb_c_hometel" length="20" />
</property>
<property name="hebVAddr" type="java.lang.String">
<column name="heb_v_addr" length="200" />
</property>
<property name="hebVEmail" type="java.lang.String">
<column name="heb_v_email" length="40" />
</property>
<property name="hbiNId" type="java.lang.Integer">
<column name="hbi_n_id" not-null="true" />
</property>
<property name="hebCIndate" type="java.lang.String">
<column name="heb_c_indate" length="14" not-null="true" />
</property>
<property name="hebCInstatus" type="java.lang.String">
<column name="heb_c_instatus" length="1" not-null="true" />
</property>
<property name="hebCType" type="java.lang.String">
<column name="heb_c_type" length="1" not-null="true" />
</property>
<property name="hebVPhoto" type="java.lang.String">
<column name="heb_v_photo" length="60" />
</property>
<property name="hebCPass" type="java.lang.String">
<column name="heb_c_pass" length="20" not-null="true" />
</property>
<property name="hebVSupperson" type="java.lang.String">
<column name="heb_v_supperson" length="40" />
</property>
<property name="hebVTemp1" type="java.lang.String">
<column name="heb_v_temp1" length="100" />
</property>
<property name="hebVTemp2" type="java.lang.String">
<column name="heb_v_temp2" length="100" />
</property>
<property name="hebVTemp3" type="java.lang.String">
<column name="heb_v_temp3" length="100" />
</property>
<set name="hrBranchInfos" inverse="true">
<key>
<column name="hbi_n_operator" />
</key>
<one-to-many class="com.pojo.HrBranchInfo" />
</set>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="com.pojo.HrDutyInfo" table="hr_duty_info" schema="public">
<id name="hdiNId" type="java.lang.Integer">
<column name="hdi_n_id" />
<generator class="sequence" />
</id>
<property name="hdiVName" type="java.lang.String">
<column name="hdi_v_name" length="40" not-null="true" />
</property>
<property name="hdiCState" type="java.lang.String">
<column name="hdi_c_state" length="1" not-null="true" />
</property>
<property name="hdiNSortindex" type="java.lang.Integer">
<column name="hdi_n_sortindex" not-null="true" />
</property>
<property name="hdiVTemp1" type="java.lang.String">
<column name="hdi_v_temp1" length="100" />
</property>
<property name="hdiVTemp2" type="java.lang.String">
<column name="hdi_v_temp2" length="100" />
</property>
<property name="hdiVTemp3" type="java.lang.String">
<column name="hdi_v_temp3" length="100" />
</property>
<set name="hrEmpBases" inverse="true">
<key>
<column name="hdi_n_id" not-null="true" />
</key>
<one-to-many class="com.pojo.HrEmpBase" />
</set>
<set name="hrRelationBranduties" inverse="true">
<key>
<column name="hdi_n_id" not-null="true" />
</key>
<one-to-many class="com.pojo.HrRelationBranduty" />
</set>
</class>
</hibernate-mapping>
非常感谢!