OneToMany没有反向关系

OneToMany没有反向关系

本文介绍了@OneToMany没有反向关系,没有连接表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与,因为我需要一个没有连接表的@OneToMany关系。但是,我也不想定义反比关系。删除反向似乎会导致一个连接表被自动生成...有没有解决这个问题的方法?

This is a similar problem to "Hibernate @OneToMany without a separate join table", in that I need a @OneToMany relationship without a join table. However, I would also like to not define the inverse relationship. Removing the inverse seems to result in a join table being automatically generated... is there a workaround for this?

推荐答案

在JPA 2.0+,您可以使用@JoinColumn作为避免生成连接表的方式。

In JPA 2.0+ you can use @JoinColumn as a way to avoid to generate joined table.

试试看。

@OneToMany
@JoinColumn(name="COLUMN_NAME")

更新

以上提供的信息已从EJB 3.0 o'reilly书中提取(查找@JoinColumn注释引用PHONE表中的CUSTOMER_ID列)。但是,普通的JPA 1.0规范不支持此功能。它说的是

The info provided above has been extracted from EJB 3.0 o'reilly book (Look for The @JoinColumn annotation references the CUSTOMER_ID column in the PHONE table). However, plain JPA 1.0 specification does not support this feature. What it says is

所以在1.0中是它是一个特定于供应商的实现(它是有道理的,作者在JBoss工作 - 在hibernate后面的红帽子部分)

So in 1.0 it is a vendor-specific implementation (And it makes sense, The author works at JBoss - The red hat divison behind the hibernate)

它由JPA 2.0实现支持
$ b

But it is supported by JPA 2.0 implementation

这篇关于@OneToMany没有反向关系,没有连接表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 03:13