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

Source: Internet
Author: User

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

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.