简体   繁体   中英

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

@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

@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?

Any help would be appreciated.

adding the following in B_RTable seems to have solved the issue :

@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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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