Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot use an @IdClass attribute for a @ManyToOne relationship
    primarykey
    data
    text
    <p>I have a <code>Gfh_i18n</code> entity, with a composite key (<code>@IdClass</code>):</p> <pre><code>@Entity @IdClass(es.caib.gesma.petcom.data.entity.id.Gfh_i18n_id.class) public class Gfh_i18n implements Serializable { @Id @Column(length=10, nullable = false) private String localeId = null; @Id &lt;-- This is the attribute causing issues private Gfh gfh = null; .... } </code></pre> <p>And the id class</p> <pre><code>public class Gfh_i18n_id implements Serializable { private String localeId = null; private Gfh gfh = null; ... } </code></pre> <p>As this is written, this works. The issue is that I also have a <code>Gfh</code> class which will have a <code>@OneToMany</code> relationship to <code>Gfh_i18n</code>:</p> <pre><code>@OneToMany(mappedBy="gfh") @MapKey(name="localeId") private Map&lt;String, Gfh_i18n&gt; descriptions = null; </code></pre> <p>Using Eclipse Dali, this gives me the following error: </p> <pre><code> In attribute 'descriptions', the "mapped by" attribute 'gfh' has an invalid mapping type for this relationship. </code></pre> <p>If I just try to do, in <code>Gfh_1i8n</code> </p> <pre><code>@Id @ManyToOne private Gfh gfh = null; </code></pre> <p>it solves the previous error but gives one in <code>Gfh_i18n</code>, stating that</p> <pre><code>The attribute matching the ID class attribute gfh does not have the correct type es.caib.gesma.petcom.data.entity.Gfh </code></pre> <p><a href="https://stackoverflow.com/questions/9617859/jpa-map-manytoone-relation-with-idclass-persistence-argumentexception">This question</a> is similar to mine, but I do not fully understand why I should be using <code>@EmbeddedId</code> (or if there is some way to use <code>@IdClass</code> with <code>@ManyToOne</code>).</p> <p>I am using JPA 2.0 over Hibernate (JBoss 6.1)</p> <p>Any ideas? Thanks in advance.</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.
 

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