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的含义,应该理解为,拥有方能够自动维护 跟被拥有方的关系;?
?? 当然,如果从被拥有方,通过手工强行来维护拥有方的关系也是可以做到的。