Tables: Table A Table B Table A_T_B A_ID B_ID A_ID Coulmn2 Columen2 B_ID Column3 Column3 Pojos : A.java B.java Set<B> bb
Type 1: we have already data present in Table B
Annotations are
@ManyToMany(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY) @JoinTable(name = " A_T_B ", joinColumns = { @JoinColumn(name = "A_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "B_ID", nullable = false, updatable = false) })
Commands executed by hibernate: Insert into Table A Insert into Table A_T_B
This works fine
Type 2: we don’t have data present in Table B
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinTable(name = "A_T_B", joinColumns = { @JoinColumn(name = "A_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "B_ID", nullable = false, updatable = false) })
Commands executed by hibernate: Insert into Table B Insert into Table A Insert into Table A_T_B
We are facing problem:
In above two scenarios we are unable to add data , if the transaction table(A_T_B) is having extra columns more than A_ID and B_ID. ...please somebody help on this please?
|