Erreur "javax.persistence.PersistenceException"
Bonjour à tous,
J'ai un problème avec Hibernate, voici le code source de mes entités.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
| package rdvmedecins.jpa;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
/**
* @author alombardo
*/
@MappedSuperclass
public class Personne implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
private Long id;
@Basic(optional = false)
@Column(name = "TITRE")
private String titre;
@Basic(optional = false)
@Column(name = "NOM")
private String nom;
@Basic(optional = false)
@Column(name = "VERSION")
@Version
private int version;
@Basic(optional = false)
@Column(name = "PRENOM")
private String prenom;
public Personne() {
}
public Personne(Long id) {
this.id = id;
}
public Personne(Long id, String titre, String nom, int version, String prenom) {
this.id = id;
this.titre = titre;
this.nom = nom;
this.version = version;
this.prenom = prenom;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTitre() {
return titre;
}
public void setTitre(String titre) {
this.titre = titre;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public String getPrenom() {
return prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
@Override
public String toString() {
return String.format("[%s,%s,%s,%s,%s]", id, version, titre, prenom, nom);
}
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| package rdvmedecins.jpa;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
/**
*
* @author alombardo
*/
@Entity
@Table(name = "clients")
@NamedQueries({
@NamedQuery(name = "Client.findAll", query = "SELECT c FROM Client c")
})
public class Client extends Personne implements Serializable {
private static final long serialVersionUID = 1L;
public Client() {
super();
}
public Client(Long id) {
super(id);
}
public Client(Long id, String titre, String nom, int version, String prenom) {
super(id, titre, nom, version, prenom);
}
@Override
public int hashCode() {
int hash = 0;
Long id = getId();
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Client)) {
return false;
}
Client other = (Client) object;
if ((this.getId() == null && other.getId() != null) || (this.getId() != null && !this.getId().equals(other.getId()))) {
return false;
}
return true;
}
@Override
public String toString() {
return String.format("Client %s", super.toString());
}
} |
et voici mon message d'erreur
Citation:
select c from Client c
Hibernate:
select
client0_.ID as ID3_,
client0_.NOM as NOM3_,
client0_.PRENOM as PRENOM3_,
client0_.TITRE as TITRE3_,
client0_.VERSION as VERSION3_
from
clients client0_
oct. 28, 2013 2:12:34 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 0, SQLState: 42703
oct. 28, 2013 2:12:34 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: ERREUR: la colonne client0_.id n'existe pas
Position*: 8
L'exception suivante s'est produite : javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: ERREUR: la colonne client0_.id n'existe pas
Position*: 8
Ma table "clients" sur la BDD PostgresSQL contient les colonnes "ID", "NOM", "VERSION", "PRENOM" et "TITRE".
Il s'agit du tutoriel de Tahé présent sur DVP.
Quelqu'un a-t-il une idée du problème ?
Merci d'avance