Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate hbm many to many mapping
    text
    copied!<p>I am trying to create a one-to-many mapping between 2 objects (work with Java). I am able to save the objects in the database, but not their relationship. I have a class called "AuthorizationPrincipal" and it contains a set of "Privileges"</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" &gt; &lt;hibernate-mapping package="org.openmrs"&gt; &lt;class name="AuthorizationPrincipal" table="authorization_principal" lazy="false"&gt; &lt;id name="authorizationPrincipalId" type="int" column="authorization_principal_id" unsaved-value="0" &gt; &lt;generator class="native" /&gt; &lt;/id&gt; &lt;discriminator column="authorization_principal_id" insert="false" /&gt; &lt;property name="name" type="java.lang.String" column="name" unique="true" length="38"/&gt; &lt;many-to-one name="creator" class="org.openmrs.User" not-null="true" /&gt; &lt;property name="uuid" type="java.lang.String" column="uuid" length="38" unique="true" /&gt; &lt;property name="dateCreated" type="java.util.Date" column="date_created" not-null="true" length="19" /&gt; &lt;property name="policy" type="java.lang.String" column="policy" not-null="true" length="255" /&gt; &lt;!-- Associations --&gt; &lt;set name="privileges" inverse="true" cascade="" table="authorization_principal_privilege" &gt; &lt;key column="authorization_principal_id" not-null="true"/&gt; &lt;many-to-many class="Privilege"&gt; &lt;column name="privilege" not-null="true" /&gt; &lt;/many-to-many&gt; &lt;/set&gt; &lt;/class&gt; </code></pre> <p></p> <p>I came up with the "set" tag by following through a few tutorials and examples, but it still won't save in the database. </p>
 

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