Issues that are ignored when federated primary key configuration Composite-id class must implement Serializable__java

Source: Internet
Author: User

Run Program error:

Context initialization failed
Org.springframework.beans.factory.BeanCreationException:Error creating Bean with Name ' Xxxxdao ' defined in file [d:\ Workspace\xxx\xxx\webapp\web-inf\classes\com\xxx\xxx\xxx\config\spring-webmanage.xml]: Cannot Resolve reference to The bean ' sessionfactory ' while the setting bean property ' sessionfactory '; Nested exception is org.springframework.beans.factory.BeanCreationException:Error creating beans with Name ' Sessionfactory ' defined in URL [Jar:file:/d:/workspace/xxx/xxx/webapp/web-inf/lib/xxx.jar!/spring-base.xml]: Invocation of Init method failed; Nested exception is org.hibernate.MappingException:Composite-id class must implement Serializable:Com.xxx.xxx.xxx.pojo.Organization
At Org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference ( beandefinitionvalueresolver.java:328)
At Org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary ( beandefinitionvalueresolver.java:106)

......

The most important error in this section is "Composite-id class must implement Serializable: "

is because it is defined as a federated primary key in the mapping file. Hbm.xml, that is, <composite-id> <composite-id>

<key-property name= "pid" type= "Java.lang.String" >

<column name= "PID"/>

</key-property>

<key-property name= "CID" type= "java.lang.String" >

<column name= "CID"/>

</key-property>

</composite-id>

Solution:

When using a federated primary key, the Bean class must be serialized

import java.io.Serializable;

Public Classbean implements Serializable {

private static final long serialversionuid = 1L;

}


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.