Note that there are some explanatory texts on larger screens.

plurals
  1. PO[Hibernate][JPA] Unknown mappedBy in .. referenced property unknown:
    primarykey
    data
    text
    <p>I have an abstract superclass "RessourceMaterielle" and an entity derived class "Vehicule". I have a 1 to 1 mapping between the sperclass and another class "Localisation". The abstract superclass is not represented in the database. I want the mapping between the superclass and the Localisation to be inherited by the derived class, so that Hibernate sees a mapping between Vehicule and Localisation. Is that possible?</p> <p>Superclass:</p> <pre><code>@MappedSuperclass public abstract class RessourceMaterielle extends ObjetMetier { private String nom = null; private Localisation localisation = null; @Column(name = "`NOM`") public String getNom() { return this.nom == null ? null : new String(this.nom); } public void setNom(String nom) { this.nom = new String(nom); } @OneToOne(cascade={CascadeType.ALL}) @JoinColumn(name="`LOCALISATION`") public Localisation getLocalisation() { return this.localisation == null ? null : this.localisation.clone(); } public void setLocalisation(Localisation localisation) { this.localisation = localisation.clone(); } public RessourceMaterielle(){ } } </code></pre> <p>Vehicule:</p> <pre><code>@Entity(name = "VEHICULE") @Table(name = "`VEHICULE`") public class Vehicule extends RessourceMaterielle { public Vehicule() { } } </code></pre> <p>Localisation:</p> <pre><code>@Entity(name = "LOCALISATION") @Table(name = "`LOCALISATION`") public class Localisation extends ObjetMetier { private double lon = -1111; private double lat = -1111; private RessourceMaterielle ressourceMaterielle; @OneToOne(cascade = { CascadeType.ALL }, mappedBy = "localisation") public RessourceMaterielle getRessourceMaterielle() { return (RessourceMaterielle) (this.ressourceMaterielle == null ? null : this.ressourceMaterielle.clone()); } public void setRessourceMaterielle(RessourceMaterielle ressourceMaterielle) { this.ressourceMaterielle = ressourceMaterielle; } @Column(name = "`LON`") public double getLon() { return this.lon; } public void setLon(double lon) { this.lon = lon; } @Column(name = "`LAT`") public double getLat() { return this.lat; } public void setLat(double lat) { this.lat = lat; } public Localisation() { } public Localisation(double lon, double lat) { this.setLon(lon); this.setLat(lat); } } </code></pre> <p>When I run a test that persists a Vehicule into the database I get the following error:</p> <pre><code>org.hibernate.AnnotationException: Unknown mappedBy in: com.organisme.model.localisation.Localisation.ressourceMaterielle, referenced property unknown: com.organisme.model.ressource.RessourceMaterielle.localisation </code></pre> <p>Is there any solution?</p> <p>Regards.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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. 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