Hibernate Federated Primary Key Composite-id mapping, querying for single primary key issues (RPM)

Source: Internet
Author: User

Today the project encountered this problem, engaged in the majority of days, I am depressed ...
Hibernate Federated Primary Key configuration (multiple fields together as primary key)

<class name= "COM.CSKJ.HIBERNATE.MAP.BBWJJC" table= "BB_WJJC" schema= "dbo" catalog= "WJGL" >
<composite-id name= "id" class= "com.cskj.hibernate.map.BbWjjcId" >
<key-property name= "Wjtmid" type= "Java.lang.Long" >
<column name= "Wjtmid"/>
</key-property>
<key-property name= "Wjxxid" type= "Java.lang.Long" >
<column name= "Wjxxid"/>
</key-property>
<key-property name= "Wjzxxid" type= "Java.lang.Long" >
<column name= "Wjzxxid"/>
</key-property>
<key-property name= "Wjztmid" type= "Java.lang.Long" >
<column name= "Wjztmid"/>
</key-property>
<key-property name= "Wjid" type= "Java.lang.Long" >
<column name= "Wjid"/>
</key-property>
</composite-id>

Generate files for primary keys

public class Bbwjjcid implements Java.io.Serializable {

Private Long Wjtmid;
Private Long Wjxxid;
Private Long Wjzxxid;
Private Long Wjztmid;
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=. Bbwjjcid to write the name of the mapping XML (that is: ID), the PK class name cannot be written.
Right Hql:from BBWJJC bw where bw.id.wjid=? Tough fix!!!

Hibernate Federated Primary Key Composite-id mapping, querying for single primary key issues (RPM)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.