Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Following works for me as an answer for question number 2:</p> <pre><code>@ForeignKey( name = "none" ) </code></pre> <p>No foreign key is being generated for the relationship.</p> <pre><code>@Cascade( value = { CascadeType.ALL } ) @OneToOne( fetch = FetchType.EAGER, orphanRemoval = true ) @JoinTable( name = "Role_Group", inverseJoinColumns = { @JoinColumn( referencedColumnName = "rolleId", name = "RolleID" ) }, joinColumns = { @JoinColumn( referencedColumnName = "groupId", name = "GroupID" ) } ) @ForeignKey( name = "none" ) public AdminRole getAdmin() </code></pre> <p>Sources:</p> <ul> <li><a href="http://blog.cherouvim.com/disabling-foreign-key-generation-in-hbm2ddl/" rel="nofollow">Disabling foreign key generation in hbm2ddl</a> </li> <li><a href="https://forum.hibernate.org/viewtopic.php?f=6&amp;t=978321" rel="nofollow">Forcing hbm2ddl to not generate an FK</a></li> </ul> <p>Based on the sources, it is an undocumented feature which was seen in release notes:</p> <pre><code>Changes in version 2.1.9 (xx.x.xxxx) ------------------------------------ * TimesTenDialect now supported (look at TimesTenDialect for certain limitations) * foreign-key="none" can be used to disable generation of a foreign key. </code></pre> <p>In xml config - you would use it like this</p> <pre><code>&lt;many-to-one name="Hospital" column="hospitalId" property-ref="hospitalId" update="false" insert="false" foreign-key="none"&gt; </code></pre> <p>as mentioned in <a href="http://blog.xebia.com/2007/02/let-hibernate-connect-your-world/" rel="nofollow">Let Hibernate Connect Your World!</a> (see the page sources - xml configuration is not shown on the page)</p> <p><strong>Note:</strong></p> <p>This does not solve the whole problem however. Hibernate cannot get the right data through this mapping table for <code>getAdmin</code> and <code>getManagers</code> as well, because it looks to <code>Role_Group</code>, finds <code>RoleIDs</code> for <code>DiscussionGroup</code> <code>GroupID</code> and has no idea if it is for <code>AdminRole</code> or <code>ManagerRole</code> and gives "<em>No row with the given identifier exists" error</em>".</p> <p>Simimilar mapping works however when I use such table in Group or DiscussionGroup as <code>public Set&lt;Role&gt; getRoles()</code>, Hibernate will successfully load derived classes (<code>AdminRole</code>, <code>ManagerRole</code>) to the Set.</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.
    1. VO
      singulars
      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