Persistance d'une Entity avec Numéro Auto
Bonjour,
J'ai une table Customer sous MySQL avec 3 champs (Num - qui est mon numéro auto, nom et prenom) que j'ai mappé en JPA. Lors de la persistance, je reçois un message d'erreur lorsque je ne fournis pas explicitement le numéro. Pourtant ça devrai se faire automatiquement. Mais lorsque je fourni le numéro, la persistance se fait sans problème.
MON ENTITY
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
| package jpaPack;
import java.io.Serializable;
import javax.persistence.*;
@Entity
@Table(name="customer")
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="Num")
private int num;
@Column(name="Nom")
private String nom;
@Column(name="Prenom")
private String prenom;
public Customer() {
}
public int getNum() {
return this.num;
}
public void setNum(int num) {
this.num = num;
}
public String getNom() {
return this.nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getPrenom() {
return this.prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
} |
MESSAGE D'ERREUR
Citation:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'scolarite.sequence' doesn't exist
Error Code: 1146
Call: UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?
bind => [2 parameters bound]
Query: DataModifyQuery(name="SEQUENCE" sql="UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?")
root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'scolarite.sequence' doesn't exist
Merci