简体   繁体   English

OnetoMany字段列表在休眠生成的表中生成列

[英]OnetoMany field List generates column in hibernate Generated Table

I am new to this, my question is that when i map a bi directional relationship as follows : 我对此并不陌生,我的问题是当我按如下方式映射双向关系时:

BTable.java BTable.java

@Entity
public class Btableimplements Serializable {

     //id and getter setters removed for simplification

     @OneToMany(mappedBy = "Btable", 
            fetch = FetchType.EAGER, 
            cascade = CascadeType.ALL)
     private List<B_rtable> tIds = new ArrayList<>();
}

Bidding_RepairTask.java Bidding_RepairTask.java

@Entity
public class B_rtable implements Serializable {

   @ManyToOne(fetch = FetchType.LAZY, optional = false)
   private BTable btable; 
}

Why does hibernate generate a tIds column in hibernate generated mysql Table for entity Bidding? 为什么hibernate在hibernate生成的mysql表中为实体招标生成tIds列?

Any help would be appreciated. 任何帮助,将不胜感激。

adding the following in B_RTable seems to have solved the issue : 在B_RTable中添加以下内容似乎已解决了该问题:

@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "b_id")
private Btable btable ;

With JPA, any fields declared in the entity are mapped to columns in the table schema. 使用JPA,在实体中声明的任何字段都将映射到表模式中的列。 If you do not want a column to exist in your table schema for the entity, you can use the @Transient annotation to exclude it. 如果您不希望实体的表架构中存在列,则可以使用@Transient批注将其排除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM