Hibernate version:
2.1.7
Mapping documents:
FilerdEd:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="com.cnpec.ims.dam.model.basicinfo.FilerdEd"
table="FILERD_ED"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="FILERD_ED"
</meta>
<composite-id name="comp_id" class="com.cnpec.ims.dam.model.basicinfo.FilerdEdPK">
<key-many-to-one name="cateNo" foreign-key="CATE_NO" >
</key-many-to-one>
<meta attribute="field-description" inherit="false">
@hibernate.id
generator-class="assigned"
</meta>
<key-property
name="cateNo"
column="CATE_NO"
type="java.lang.Long"
length="5"
access=""
>
<meta attribute="field-description">
@hibernate.property
column="CATE_NO"
length="5"
</meta>
</key-property>
<key-property
name="edNo"
column="ED_NO"
type="java.lang.Long"
length="10"
>
<meta attribute="field-description">
@hibernate.property
column="ED_NO"
length="10"
</meta>
</key-property>
</composite-id>
<property
name="ynTech"
type="java.lang.String"
column="YN_TECH"
length="1"
>
<meta attribute="field-description">
@hibernate.property
column="YN_TECH"
length="1"
</meta>
</property>
<property
name="mainActi"
type="java.lang.String"
column="MAIN_ACTI"
length="2"
>
<meta attribute="field-description">
@hibernate.property
column="MAIN_ACTI"
length="2"
</meta>
</property>
<property
name="subActi"
type="java.lang.String"
column="SUB_ACTI"
length="5"
>
<meta attribute="field-description">
@hibernate.property
column="SUB_ACTI"
length="5"
</meta>
</property>
<property
name="proNo"
type="java.lang.String"
column="PRO_NO"
length="20"
>
<meta attribute="field-description">
@hibernate.property
column="PRO_NO"
length="20"
</meta>
</property>
<property
name="sysCd"
type="java.lang.String"
column="SYS_CD"
length="3"
>
<meta attribute="field-description">
@hibernate.property
column="SYS_CD"
length="3"
</meta>
</property>
<property
name="bldCd"
type="java.lang.String"
column="BLD_CD"
length="3"
>
<meta attribute="field-description">
@hibernate.property
column="BLD_CD"
length="3"
</meta>
</property>
<property
name="title"
type="java.lang.String"
column="TITLE"
length="200"
>
<meta attribute="field-description">
@hibernate.property
column="TITLE"
length="200"
</meta>
</property>
<property
name="remark"
type="java.lang.String"
column="REMARK"
length="200"
>
<meta attribute="field-description">
@hibernate.property
column="REMARK"
length="200"
</meta>
</property>
<!-- Associations -->
<!-- derived association(s) for compound key -->
<!-- bi-directional many-to-one association to FilerdEdcate -->
<many-to-one
name="filerdEdcate"
class="com.cnpec.ims.dam.model.basicinfo.FilerdEdcate"
update="false"
insert="false"
>
<meta attribute="field-description">
@hibernate.many-to-one
update="false"
insert="false"
</meta>
<meta attribute="field-description">
@hibernate.column
name="CATE_NO"
</meta>
<column name="CATE_NO"/>
</many-to-one>
<!-- end of derived association(s) -->
<!-- bi-directional one-to-many association to FilerdEdd -->
<set
name="filerdEdds"
lazy="true"
inverse="true"
cascade="none"
>
<meta attribute="field-description">
@hibernate.set
lazy="true"
inverse="true"
cascade="none"
@hibernate.collection-key
column="CATE_NO"
@hibernate.collection-key
column="ED_NO"
@hibernate.collection-one-to-many
class="com.cnpec.ims.dam.model.basicinfo.FilerdEdd"
</meta>
<key>
<column name="CATE_NO"/>
<column name="ED_NO"/>
</key>
<one-to-many
class="com.cnpec.ims.dam.model.basicinfo.FilerdEdd"
/>
</set>
</class>
</hibernate-mapping>
FilerdEdd:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="com.cnpec.ims.dam.model.basicinfo.FilerdEdd"
table="FILERD_EDD"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="FILERD_EDD"
</meta>
<composite-id name="comp_id" class="com.cnpec.ims.dam.model.basicinfo.FilerdEddPK">
<meta attribute="field-description" inherit="false">
@hibernate.id
generator-class="assigned"
</meta>
<key-property
name="cateNo"
column="CATE_NO"
type="java.lang.Long"
length="5"
>
<meta attribute="field-description">
@hibernate.property
column="CATE_NO"
</meta>
</key-property>
<key-property
name="edNo"
column="ED_NO"
type="java.lang.Long"
length="10"
>
<meta attribute="field-description">
@hibernate.property
column="ED_NO"
</meta>
</key-property>
<key-property
name="distDept"
column="DIST_DEPT"
type="java.lang.String"
length="20"
>
<meta attribute="field-description">
@hibernate.property
column="DIST_DEPT"
</meta>
</key-property>
<key-property
name="distCl"
column="DIST_CL"
type="java.lang.String"
length="6"
>
<meta attribute="field-description">
@hibernate.property
column="DIST_CL"
</meta>
</key-property>
</composite-id>
<property
name="ynInternal"
type="java.lang.String"
column="YN_INTERNAL"
length="2"
>
<meta attribute="field-description">
@hibernate.property
column="YN_INTERNAL"
length="2"
</meta>
</property>
<property
name="remark"
type="java.lang.String"
column="REMARK"
length="200"
>
<meta attribute="field-description">
@hibernate.property
column="REMARK"
length="200"
</meta>
</property>
<!-- Associations -->
<!-- derived association(s) for compound key -->
<!-- bi-directional many-to-one association to FilerdEd -->
<many-to-one
name="filerdEd"
class="com.cnpec.ims.dam.model.basicinfo.FilerdEd"
update="false"
insert="false"
>
<meta attribute="field-description">
@hibernate.many-to-one
update="false"
insert="false"
</meta>
<meta attribute="field-description">
@hibernate.column
name="CATE_NO"
</meta>
<meta attribute="field-description">
@hibernate.column
name="ED_NO"
</meta>
<column name="CATE_NO" />
<column name="ED_NO" />
</many-to-one>
<!-- end of derived association(s) -->
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
net.sf.hibernate.QueryException: path expression ends in a composite value: filerdedd0_.filerdEd [select count(*) from com.cnpec.ims.dam.model.basicinfo.FilerdEdd a where 1=1 and
a.filerdEd = ? ]
Name and version of the database you are using:
Oracle 10g
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
it is one-to-many relationship between FilerdEd and FilerdEdd, and FilerdEd is a composite id Model. I generate the HQL:
select count(*) from com.cnpec.ims.dam.model.basicinfo.FilerdEdd a where 1=1 and a.filerdEd = ?
according to FilerdEdd instance, but it does not work, what's the problem?Thanks!