Associations marked as mappedBy must not define database mappings like @JoinTable or @JoinColumn【报错】

自己的项目没有测通  可能是自己项目原因——因为自己项目中级联关系的类涉及太多

自己的项目【这样的配置报错】

@OneToMany(fetch=FetchType.LAZY,cascade = { CascadeType.REMOVE }, mappedBy="scProjectTecApply")
@JoinColumn(name="busid")
public List<ScTeam> getTeams() {
return teams;
}

【修改后配置】

@OneToMany(fetch=FetchType.LAZY,cascade = { CascadeType.REMOVE }, mappedBy="scProjectTecApply")
public List<ScTeam> getTeams() {
return teams;
=======================报错

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 busid80_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 teams0_ where teams0_.scProjectTecApply=?];

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column ‘teams0_.scProjectTecApply‘ in ‘field list‘

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

【修改为这样】仍然报错

@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_.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 teams0_ where teams0_.busid=?]; 
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column ‘teams0_.scProjectTecApply‘ in ‘field list‘

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

【网上资料】

异常:Associations marked as mappedBy must not define database mappings like @JoinTable or @JoinColumn
错误发生在下面这些代码中
@OneToMany(mappedBy="parent",fetch=FetchType.EAGER,cascade=CascadeType.ALL)
@JoinColumn(name="parent_id")
private List<Category> child = new ArrayList<Category>();
后来发现在3.5.3版本中@JoinColumn与mappingBy是互斥的,之前在hibernate.3.3.2中都是正确无误的,也就是hibernate.3.3.2允许这两个互相存在。
所以,如果升级到hibernate3.5.3想测试成功的话,mappBy="parent",就应该去掉,正确的配置应该是这样
@OneToMany(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
@JoinColumn(name="parent_id")
private List<Category> child = new ArrayList<Category>();

时间: 2024-10-29 01:10:43

Associations marked as mappedBy must not define database mappings like @JoinTable or @JoinColumn【报错】的相关文章

zabbix启动报错:Connection to database &#39;xxx&#39; failed解决方法

Zabbix 分布式系统监视系统 zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案. zabbix能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题. 本文讲解的是zabbix无法启动报错:Connection to database 'xxx' failed: [1045] Access denied for user 'xxx'@'localhost' (using password: NO)

spriing boot 启动报错:Cannot determine embedded database driver class for database type NONE

最近在学习使用spring boot.使用maven创建好工程,只引用需要用到的spring boot相关的jar包,除此之外没有任何的配置. 写了一个最简单的例子,如下所示: 1 package com.torlight; 2 3 import org.springframework.boot.SpringApplication; 4 import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 import

关于spring-data-mongodb用户名密码登录报错问题:Failed to authenticate to database

一.问题 1.spring-data-mongodb用户名密码登录报错问题:Failed to authenticate to database  org.springframework.data.mongodb.CannotGetMongoDbConnectionException: Failed to authenticate to database [ashop], username = [ashop], password = [g***********4] org.springframe

一看便知linux下mysql报错ERROR 1044: Access denied for user: &#39;@localhost&#39; to database &#39;mysql&#39;

错误信息:ERROR 1044: Access denied for user: '@localhost' to database 'mysql' linux下解决方案: mysql> use mysql ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'mysql' mysql> exit Bye [[email protected] ~]# service mysqld stop如果该命令不

RMAN恢复报错: ORA-01103: database name &#39;POWERDES&#39; in control file is not &#39;PDUNQ&#39;

执行rman恢复的时候报错 RMAN> alter database mount; RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: ====================================================

SQLITE报错database is locked的解决办法

用firedac连接SQLITE数据库,空间tdbedit绑定字段name,如下语句修改其值时报错. procedure TForm1.Button3Click(Sender: TObject);begin fdquery.Edit; fdquery.FieldByName('name').AsString:='test2'; fdquery.post;   //执行到这里报错 [FireDAC][Phys][SQLite] ERROR: database is locked. 换成refres

yum安装出现Error: database disk image is malformed报错

使用yum安装gcc命令时,电脑意外重启,恢复虚拟机后再次使用yum安装gcc出现报错信息 Error: database disk image is malformed 报错原因是之前意外结束安装进程之前已经产生了缓存 使用yum重新安装的时候首先要清除缓存,使用yum clean all命令 yum clean all 清除yum缓存,使用yum安装软件包时yum把下载的软件包和header存储在cache中,进程意外中断后之前下载的内容不会自动删除,我们需要先清空缓存后再重新下载.当然,如

mysql忘记root密码或报错:ERROR 1044 (42000): Access denied for user ”@’localhost’ to database ‘xx‘

有的时候忘记了root密码或其他用户的密码,登录的时候报错:ERROR 1044 (42000): Access denied for user ”@’localhost’ to database 'xx'.下面是具体的解决方法: 1.关闭mysql #service mysqld stop 2.屏蔽权限 # mysqld_safe --skip-grant-table 3.新开起一个终端输入 # mysql -u root mysql # mysql> UPDATE user SET Pass

Table &#39;.\mysql\proc&#39; is marked as crashed and should be repaired 报错

Table '.\MySQL\proc' is marked as crashed and should be repaired 报错 解决方法: 找到mysql的安装目录的bin/myisamchk工具,在命令行中输入: myisamchk -c -r ../data/mysql/proc.MYI 然后myisamchk 工具会帮助你恢复数据表的索引.重新启动mysql,问题解决. Table '.\mysql\proc' is marked as crashed and should be