`

mappedBy跟JoinColumn/JoinTable

阅读更多

在对网站进行升级的时候,hibernate升级为最新的3.5.1版本的时候,发现了有个异常

Associations marked as mappedBy must not define database mappings like @JoinTable or @JoinColumn:*******

我说明mappedBy跟JoinColumn/JoinTable是互斥的。

在以前的版本中都是可以的,在@ManyToMany 中两个标签都写了。没有发现问题。现在却出现了这个问题~

这是不是hibernate完全支持JPA2的原因呢。。

 

对于mappedBy复习下:

a) 只有OneToOne,OneToMany,ManyToMany上才有mappedBy属性,ManyToOne不存在该属性;
b) mappedBy标签一定是定义在the owned side(被拥有方的),他指向the owning side(拥有方);
c) mappedBy的含义,应该理解为,拥有方能够自动维护 跟被拥有方的关系;

 

   当然,如果从被拥有方,通过手工强行来维护拥有方的关系也是可以做到的。
d) mappedBy跟JoinColumn/JoinTable总是处于互斥的一方,可以理解为正是由于拥有方的关联被拥有方的字段存在,拥有方才拥有了被 拥有方。mappedBy这方定义的JoinColumn/JoinTable总是失效的,不会建立对应的字段或者表

分享到:
评论
2 楼 icolorfulday 2013-03-17  
dfafaaffaaf
1 楼 lai555 2011-08-01  
hibernate 我也是从3.3升级到3.6 出现了这问题,请问您是怎么解决呢、

相关推荐

    一个struts2的例子:彻底解决STRUTS2 错误There is no Action mapped for namespace / and action name login

    前几天在网上下载一个struts2的helloword的例子,那个作者也真够缺德的,搞个错误的程序,害得我查了一天的程序错误。 最后发现竟然是struts.xml被写成啦sturts.xml。 碰见这样的问题先鄙视下提供例子的作者, ...

    HTTP Status 404 - There is no Action

    HTTP Status 404 - There is no Action mapped for namespace and action name BackMemberGroupAudit..doc

    mappedBy属性:one2many

    NULL 博文链接:https://605113068.iteye.com/blog/1727088

    Hibernate_Annotation关联映射

    通过@JoinTable批注定义关联表,该关联表包含了指回实体表的外键(通过@JoinTable.joinColoumns)以及指向目标实体表的外键(通过@JoinTable.inverseJoinColoumns) @Entity @Table(name="Test_TreeType") public class ...

    java的实现权限控制shiro jwt.docx

    protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) { // 查看当前Header中是否携带Authorization属性(Token),有的话就进行登录认证授权 if (this....

    hibernate_UD

    请测试代码并查看测试,我建议您@JoinColumn批注,并将mappedBy放在报告的另一侧。 也可以使用@JoinTable批注完成此@JoinTable 。 @JoinTable批注指示关系的所有者-相应的表包含所引用表的外键列。 @Entity ...

    TestAutoGenerateID

    解决问题:Concurrency violation: the UpdateCommand...SchemaType.Mapped);//new added adapter.Fill(ds); 这样,在 adapter.Update(ds); 时就可以自动得到自增列的值;从而,不会保存失败了。 (自增列应为主键)

    model:幼稚SQL去结构

    Age int // not mapped Gender byte // not mapped // works with embedded structs Bio struct { Name string `sql:"name"` Surname string `sql:"last_name"` } } 创建一个指针并添加一些数据: user :...

    Hibernate注解 关联关系映射注解.docx

    mappedBy属性用法:  该属性与关联关系的维护权相关。  该属性应放在放弃维护权一方。  该属性值为对方的关联属性,表明以后的关联关系将由它来负责。  使用该属性的注解,无需也不能再设置cascade属性。 ...

    Hibernate注释大全收藏

    @AssociationOverride( name="id.channel", joinColumns = @JoinColumn(name="chan_id") ) public class TvMagazin { @EmbeddedId public TvMagazinPk id; @Temporal(TemporalType.TIME) Date time; } @...

    服务器架构ppt.pptx

    WebFOCUS 架构Web服务概览 Web服务 ibi_html approot 主要存放静态页面和静态内容 /ibi_html mapped to ../ibi/WebFOCUS76/ibi_html Common Templates and Forms Images, Icons, Scripts and Stylesheets MR ...

    第14章:网络编程(day20).zip

    [[03 08:58:23,230 INFO ] org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:314) - Mapped URL path [/schoolApiService.hs] onto handler '/...

    docker:用于devtest的各种Docker文件

    #launch 5 containers, host volume mapped to /opt/data/ubuntu-N $ launch-docker-containers ubuntu mytag 5 #stop only containers named ubuntu $ stop-docker-containers ubunt* #stop and remove containers ...

    BOS 技术整理

    @ManyToMany 一方写 mappedBy 放弃外键维护、另一方 @JoinTable 维护中间表 收派标准修添加能实现 html 请求 后台处理 服务器端Service和DAO编写整合springdatajpa 业务层接口 修改 Action 代码调用 ...

    Ambiguous mapping. Cannot map *** method 报错解决

    开发中,我们常常会遇到很多异常报错,现在就我工作中经常遇到的报错做记录和总结,首先对自己会有很大的帮助,同时希望对读者也起到一定的帮助。废话不多说,先上报错。 1. Ambiguous mapping....

    jaeger-client-micrometer:通过测微表公开的Jaeger客户端指标用于Spring Boot 2.x应用程序

    Mapped "{[/actuator/prometheus],methods=[GET],produces= ... 如果是这种情况,那么Jaeger指标应该与其他指标一起可用: $ curl localhost:8080/actuator/prometheus 2>/dev/null | grep jaeger# HELP jaeger:

    MemoryMappedFile 使用 共享内存循环读写

    MemoryMappedFile 使用 C# 内存中分配一大块地址. 前边分配一个用与共同配置用 后边N个结构体 for循环建 一般用到此问题,两本程序 一个读一个写 循环读写 ----2015/09/24 Lyndon 上海----

    黑金zynq教程

    黑金zynq入门教程,ALINX黑金Zynq7000开収平台 配套教程第二部

    Hibernate注解

    * 从表:@OneToOne(mappedBy = "主表类中的从表属性")//例主表User中有一个从表属性是Heart类型的heart,这里就填heart * public 主表类 get主表类(){return 主表对象} * 注意:@JoinColumn是可选的。默认值是从表...

    Memory Mapped File Demo in WinCE

    利用Memory Mapped File实践A,B跨程序的数据交换

Global site tag (gtag.js) - Google Analytics