edit: sorry for my eventual newbieness, i've tried to follow the doc but i may have missed some key concepts
Hey there, so basically i have a Personne class
Code:
public class Personne {
Integer id;
String nom;
String prenom;
Integer codePostal;
String adresse;
String ville;
String naissance;
String mail;
String telephone;
ArrayList<CV> cvs;
ArrayList<String> permis;
Integer role;
String login;
String motDePasse;
Double longitude;
Double latitude;
with it's hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Dec 4, 2014 10:28:55 AM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="fr.itescia.cevetek.administration.Personne" table="PERSONNE">
<id name="id" type="java.lang.Integer">
<column name="ID" />
<generator class="native" />
</id>
<property name="nom" type="java.lang.String">
<column name="NOM" />
</property>
<property name="prenom" type="java.lang.String">
<column name="PRENOM" />
</property>
<property name="codePostal" type="java.lang.Integer">
<column name="CODEPOSTAL" />
</property>
<property name="adresse" type="java.lang.String">
<column name="ADRESSE" />
</property>
<property name="ville" type="java.lang.String">
<column name="VILLE" />
</property>
<property name="naissance" type="java.lang.String">
<column name="NAISSANCE" />
</property>
<property name="mail" type="java.lang.String">
<column name="MAIL" />
</property>
<property name="telephone" type="java.lang.String">
<column name="TELEPHONE" />
</property>
<list name="cvs" inverse="false" table="CV" lazy="true">
<key>
<column name="ID" />
</key>
<list-index>
<column name="idx" />
</list-index>
<one-to-many class="fr.itescia.cevetek.exportation.CV" />
</list>
<list name="permis" inverse="false" table="PERSONNE" lazy="true">
<key>
<column name="ID" />
</key>
<list-index></list-index>
<element type="java.lang.String">
<column name="PERMIS" />
</element>
</list>
<property name="role" type="java.lang.Integer">
<column name="ROLE" />
</property>
<property name="login" type="java.lang.String">
<column name="LOGIN" />
</property>
<property name="motDePasse" type="java.lang.String">
<column name="MOTDEPASSE" />
</property>
<property name="latitude" type="org.hibernatespatial.GeometryUserType" column="latitude"/>
<property name="longitude" type="org.hibernatespatial.GeometryUserType" column="longitude"/>
</class>
</hibernate-mapping>
as you can see the Personne has an ArrayList of CV as attribute with one (Personne) to many (CV) Mapping
the CV class is like that
Code:
public class CV {
Integer id;
ArrayList<Formation> formations;
ArrayList<Experience> experiences;
ArrayList<Competence> competences;
ArrayList<Langue> langues;
ArrayList<Loisir> loisirs;
Date dateModif;
Date dureeSupp;
and it's hbm.xml is like this
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Dec 4, 2014 10:28:55 AM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="fr.itescia.cevetek.exportation.CV" table="CV">
<id name="id" type="java.lang.Integer">
<column name="ID_CV" />
<generator class="native" />
</id>
<list name="formations" inverse="false" table="FORMATION" lazy="true">
<key>
<column name="ID" />
</key>
<list-index></list-index>
<one-to-many class="fr.itescia.cevetek.profil.Formation" />
</list>
<list name="experiences" inverse="false" table="EXPERIENCE" lazy="true">
<key>
<column name="ID" />
</key>
<list-index></list-index>
<one-to-many class="fr.itescia.cevetek.profil.Experience" />
</list>
<list name="competences" inverse="false" table="COMPETENCE" lazy="true">
<key>
<column name="ID" />
</key>
<list-index></list-index>
<one-to-many class="fr.itescia.cevetek.profil.Competence" />
</list>
<list name="langues" inverse="false" table="LANGUE" lazy="true">
<key>
<column name="ID" />
</key>
<list-index></list-index>
<one-to-many class="fr.itescia.cevetek.profil.Langue" />
</list>
<list name="loisirs" inverse="false" table="LOISIR" lazy="true">
<key>
<column name="ID" />
</key>
<list-index></list-index>
<one-to-many class="fr.itescia.cevetek.profil.Loisir" />
</list>
<property name="dateModif" type="java.sql.Date">
<column name="DATEMODIF" />
</property>
<property name="dureeSupp" type="java.sql.Date">
<column name="DUREESUPP" />
</property>
</class>
</hibernate-mapping>
And Basically when i try a session.save(personne); for a single Personne i get the following error:
"Foreign key (FK_g4uaceies78lhtnyyl79k3pjm:CV [ID])) must have same number of columns as the referenced primary key (PERSONNE [ID,idx])"
from what i understand hibernate see the primary key of the PERSONNE table as a composite key, while i've never defined it anywhere? and on the other side it see the primary key of CV as single key, while it should have the index.... can anyone explain me what i'm missing? should it be a many to one mapping? should i had a composite key to cv instead of a single ID?
regards,
Golgoth