Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate map several relationship to same table
    primarykey
    data
    text
    <p>I have the following ER: <img src="https://i.stack.imgur.com/KIMRi.png" alt="Entity Relationship"></p> <p>I want to know how I can map the third table using hibernate. I have this code:</p> <pre><code>@ManyToOne(optional = false) @JoinColumns({ @JoinColumn(name = "tbl3_tbl1_id", referencedColumnName = "tbl2_tbl1_id", insertable = false, updatable = false), @JoinColumn(name = "tbl3_tbl2_id", referencedColumnName = "tbl2_id", insertable = false, updatable = false)}) public TableDB getTableDB() { return tableDB; } @OneToOne(optional = false) @JoinColumns({ @JoinColumn(name = "tbl3_tbl1_id", referencedColumnName = "tbl2_tbl1_id", insertable = false, updatable = false), @JoinColumn(name = "tbl3_tbl2_id_2", referencedColumnName = "tbl2_id", insertable = false, updatable = false)}) public TableDB getTableDB2() { return tableDB2; } @OneToOne(optional = false) @JoinColumns({ @JoinColumn(name = "tbl3_tbl1_id", referencedColumnName = "tbl2_tbl1_id", insertable = false, updatable = false), @JoinColumn(name = "tbl3_tbl2_id_3", referencedColumnName = "tbl2_id", insertable = false, updatable = false)}) public TableDB getTableDB3() { return tableDB3; } </code></pre> <p>The problem lies in the one to one 2 and 3. When I call the method "save" the insertion code is something like this:</p> <pre><code>insert into table3 (tbl3_desc, tbl3_id, tbl3_tbl1_id, tbl3_tbl2_id) values (?, ?, ?, ?) </code></pre> <p>Where is the column <code>tbl3_tbl2_id_2, tbl3_tbl2_id_3</code> ?</p> <p>Any comments or advice?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload