Today the project encountered this problem, engaged in the majority of days, now recorded
Hibernate Federated Primary Key configuration (multiple fields together as primary key)
<classname= "COM.CSKJ.HIBERNATE.MAP.BBWJJC"Table= "BB_WJJC"Schema= "dbo"Catalog= "WJGL"> <Composite-idname= "id"class= "Com.cskj.hibernate.map.BbWjjcId"> <Key-propertyname= "Wjtmid"type= "Java.lang.Long"> <columnname= "Wjtmid" /> </Key-property> <Key-propertyname= "Wjxxid"type= "Java.lang.Long"> <columnname= "Wjxxid" /> </Key-property> <Key-propertyname= "Wjzxxid"type= "Java.lang.Long"> <columnname= "Wjzxxid" /> </Key-property> <Key-propertyname= "Wjztmid"type= "Java.lang.Long"> <columnname= "Wjztmid" /> </Key-property> <Key-propertyname= "Wjid"type= "Java.lang.Long"> <columnname= "Wjid" /> </Key-property> </Composite-id>
Generate files for primary keys
Public class Implements Private privateprivate private Private Long Wjid; }
Use the HQL statement when querying a single primary key
From BBWJJC bw where bw. Bbwjjcid.wjid=?
Result Error:
Could not resolve Property:bbwjjcid OF:COM.CSKJ.HIBERNATE.MAP.BBWJJC [from COM.CSKJ.HIBERNATE.MAP.BBWJJC bw where bw. Bbwjjcid.wjid= ' 5 ']
On the internet to check a bit, said is the problem of HQL statement.
Test the most of the day results debugging is normal, the original is bw. Bbwjjcid.wjid=? The bbwjjcid in the mapping XML to write the name (ie: ID), cannot write the PK class name.
Right Hql:from BBWJJC bw where bw.id.wjid=? Hard to fix!!!
Hibernate Federated Primary Key Composite-id mapping, querying for single primary key issues