Associations marked as Mappedby must not define database mappings like @JoinTable or @JoinColumn "error"

Source: Internet
Author: User

Your project does not have a test pass may be the cause of your project-because the class of your project Intermediate association involves too many

Own project "Such a configuration error"

@OneToMany (Fetch=fetchtype.lazy,cascade = {Cascadetype.remove}, mappedby= "Scprojecttecapply")
@JoinColumn (name= "Busid")
Public list<scteam> Getteams () {
return teams;
}

"Post-modification Configuration"

@OneToMany (Fetch=fetchtype.lazy,cascade = {Cascadetype.remove}, mappedby= "Scprojecttecapply")
Public list<scteam> Getteams () {
return teams;
======================= Error

Could not initialize a collection:

[com.jspxcms.core.domain.scprojecttecapply.teams#2098];

SQL [Select Teams0_.scprojecttecapply as scprojec6_77_1_, teams0_.id as id1_, teams0_.id as id80_0_, Teams0_.busid as Busi d80_0_, Teams0_.deptname as deptname80_0_, Teams0_.leader as leader80_0_, teams0_.points as points80_0_, teams0_. Scprojecttecapply as scprojec6_80_0_, teams0_.uname as uname80_0_, Teams0_.weight_sort as weight8_80_0_ from Sc_team team s0_ where teams0_.scprojecttecapply=?];

Com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column ' teams0_.scprojecttecapply ' in ' Field List '

=============

"Modified to this" still error

@OneToMany (Fetch=fetchtype.lazy,cascade = {Cascadetype.remove})
@JoinColumn (name= "Busid")
Public list<scteam> Getteams () {
return teams;
}

Could not initialize a collection:

[com.jspxcms.core.domain.scprojecttecapply.teams#2098];

SQL [Select Teams0_.busid as busid77_1_, teams0_.id as id1_, teams0_.id as id80_0_, Teams0_.busid as busid80_0_, TEAMS0_.D Eptname as deptname80_0_, Teams0_.leader as leader80_0_, teams0_.points as points80_0_, teams0_.scprojecttecapply as scprojec6_80_0_, teams0_.uname as uname80_0_, Teams0_.weight_sort as weight8_80_0_ from Sc_team teams0_ where teams 0_.busid=?];
Com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:Unknown column 'teams0_.scprojecttecapply' in ' Field List '

=====================

"Online Information"

Exception: Associations marked as Mappedby must not define database mappings like @JoinTable or @JoinColumn
The error occurs in the following code
@OneToMany (mappedby= "parent", Fetch=fetchtype.eager,cascade=cascadetype.all)
@JoinColumn (name= "parent_id")
Private list<category> child = new arraylist<category> ();
Later found in 3.5.3 Release @joincolumn and Mappingby are mutually exclusive, before in hibernate.3.3.2 is correct, that is, hibernate.3.3.2 allow the two to exist.
So, if the upgrade to hibernate3.5.3 want to test success, mappby= "parent", should be removed, the correct configuration should be
@OneToMany (Fetch=fetchtype.eager,cascade=cascadetype.all)
@JoinColumn (name= "parent_id")
Private list<category> child = new arraylist<category> ();

Associations marked as Mappedby must not define database mappings like @JoinTable or @JoinColumn "error"

Related Article

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.