jeudi 26 février 2015

JPA does not create subclasses

i am working on a project with springMvc and JPA Eclipselink , i've created some beans and eclipselink created the tables , but my problem is that i've some inheritence relations : Person with Quality Analyst , the table Person is created but the table Quality analyst is not created.


this is the SuperClass Personne, no problem here . package com.hpcdg.quality.entities.Acteurs; import java.util.Date;



import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.InheritanceType;
import javax.persistence.DiscriminatorType;
@Entity
@Table(name="Personne")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="discriminator",
discriminatorType=DiscriminatorType.STRING
)
@DiscriminatorValue(value="per")
public class Personne {

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int personneID;

@Column
private String matriculation;

@Column
private String nom;

@Column
private String prenom;

@Column
private String email;

@Column
private String telephone;

@Temporal(TemporalType.DATE)
@Column
private Date anc;

@Temporal(TemporalType.DATE)
@Column
private Date enposte;

@Column
private String poste;

public String getPoste() {
return poste;
}
public void setPoste(String poste) {
this.poste = poste;
}
public int getPersonneID() {
return personneID;
}
public void setPersonneID(int personneID) {
this.personneID = personneID;
}
public String getMatriculation() {
return matriculation;
}
public void setMatriculation(String matriculation) {
this.matriculation = matriculation;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getPrenom() {
return prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public Date getAnc() {
return anc;
}
public void setAnc(Date anc) {
this.anc = anc;
}
public Date getEnposte() {
return enposte;
}
public void setEnposte(Date enpost) {
this.enposte = enpost;
}


}


and now the Quality Analyst bean , not created in the db package com.hpcdg.quality.entities.Acteurs;



import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name="QualityAnalyst")
@DiscriminatorValue("QA")

public class QualityAnalyst extends PersonneAvecEcoute {

@Column
private int id;

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

}


and finaly my persistance.xml



<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://ift.tt/1cKbVbQ" xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/1cKbVbQ http://ift.tt/1kMb4sd">
<persistence-unit name="SpringData"
transaction-type="RESOURCE_LOCAL">

<class>com.hpcdg.quality.entities.Authentification.Role</class>
<class>com.hpcdg.quality.entities.Authentification.Compte</class>
<class>com.hpcdg.quality.entities.Acteurs.Personne</class>
<class>com.hpcdg.quality.entities.Acteurs.Agent</class>
<class>com.hpcdg.quality.entities.Acteurs.Coach</class>
<class>com.hpcdg.quality.entities.Acteurs.Formateur</class>
<class>com.hpcdg.quality.entities.Acteurs.PersonneAvecEcoute</class>
<class>com.hpcdg.quality.entities.Acteurs.QualityAnalyst</class>
<class>com.hpcdg.quality.entities.Acteurs.SDM</class>
<class>com.hpcdg.quality.entities.Acteurs.SDS</class>
<class>com.hpcdg.quality.entities.Acteurs.TeamLeader</class>



<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/QualityDB" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="eclipselink.logging.level" value="OFF" />
<property name="eclipselink.ddl-generation" value="create-or-extend-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
</properties>
</persistence-unit>
</persistence>


hope that you can help me with that, why my quality analyst entity is not persisting in my db


Aucun commentaire:

Enregistrer un commentaire