Salut

J'ai un probleme avec une requete JPA.

Ma configuration est Mysql5 en base de données et tomcat en serveur.

J'ai une table Personne basique ou j'ai mis une clé primaire.

Je mets une annotation @GeneratedValue(strategy=GenerationType.AUTO)

sur cette colonne(ex:ID_Personne).

je teste l'application avec le code suivant:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
EntityManagerFactory emf;
		 EntityManager em;
		 String PERSISTENCE_UNIT_NAME = "jpapersonne";
		 emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
	     em = emf.createEntityManager();
 
	     EntityTransaction transac = em.getTransaction();
 
	     transac.begin();
 
	     Personne nouvellePersonne = new Personne();
	     nouvellePersonne.setNom_personne("nom4");
	     em.persist(nouvellePersonne);
 
	     transac.commit();
 
	     em.close();   
 
	     emf.close();
et mon message d'erreur est la suivante:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
[EL Info]: 2011-05-19 00:15:30.062--ServerSession(18306082)--EclipseLink, version: Eclipse Persistence Services - 2.1.2.v20101206-r8635
[EL Info]: 2011-05-19 00:15:30.562--ServerSession(18306082)--file:/E:/developppement/workspace/jpapersonne/build/classes/_jpapersonne login successful
[EL Warning]: 2011-05-19 00:15:30.687--UnitOfWork(20435088)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.2.v20101206-r8635): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Erreur de syntaxe près de 'adresse, id_animaux, Nom_personne, password, photo) VALUES (0, null, 0, 0, 'nom4' à la ligne 1
Error Code: 1064
Call: INSERT INTO personne (ID_personne, prenom_personne, numero adresse, id_animaux, Nom_personne, password, photo) VALUES (?, ?, ?, ?, ?, ?, ?)
	bind => [0, null, 0, 0, nom4, 0, 0]
Query: InsertObjectQuery(jpa.Personne@12bcd4b)
Exception in thread "main" javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.2.v20101206-r8635): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Erreur de syntaxe près de 'adresse, id_animaux, Nom_personne, password, photo) VALUES (0, null, 0, 0, 'nom4' à la ligne 1
Error Code: 1064
Call: INSERT INTO personne (ID_personne, prenom_personne, numero adresse, id_animaux, Nom_personne, password, photo) VALUES (?, ?, ?, ?, ?, ?, ?)
	bind => [0, null, 0, 0, nom4, 0, 0]
Query: InsertObjectQuery(jpa.Personne@12bcd4b)
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:102)
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
	at jpa.main.main(main.java:28)
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.2.v20101206-r8635): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Erreur de syntaxe près de 'adresse, id_animaux, Nom_personne, password, photo) VALUES (0, null, 0, 0, 'nom4' à la ligne 1
Error Code: 1064
Call: INSERT INTO personne (ID_personne, prenom_personne, numero adresse, id_animaux, Nom_personne, password, photo) VALUES (?, ?, ?, ?, ?, ?, ?)
	bind => [0, null, 0, 0, nom4, 0, 0]
Query: InsertObjectQuery(jpa.Personne@12bcd4b)
	at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:797)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:863)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:583)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:526)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeCall(AbstractSession.java:980)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:206)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:192)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.insertObject(DatasourceCallQueryMechanism.java:341)
	at org.eclipse.persistence.internal.queries.StatementQueryMechanism.insertObject(StatementQueryMechanism.java:162)
	at org.eclipse.persistence.internal.queries.StatementQueryMechanism.insertObject(StatementQueryMechanism.java:177)
	at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.insertObjectForWrite(DatabaseQueryMechanism.java:465)
	at org.eclipse.persistence.queries.InsertObjectQuery.executeCommit(InsertObjectQuery.java:80)
	at org.eclipse.persistence.queries.InsertObjectQuery.executeCommitWithChangeSet(InsertObjectQuery.java:90)
	at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:290)
	at org.eclipse.persistence.queries.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:58)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:740)
	at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:643)
	at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:108)
	at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:85)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2908)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1291)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1273)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1233)
	at org.eclipse.persistence.internal.sessions.CommitManager.commitNewObjectsForClassWithChangeSet(CommitManager.java:224)
	at org.eclipse.persistence.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:123)
	at org.eclipse.persistence.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:3348)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1422)
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:610)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1527)
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:264)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1148)
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)
	... 2 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Erreur de syntaxe près de 'adresse, id_animaux, Nom_personne, password, photo) VALUES (0, null, 0, 0, 'nom4' à la ligne 1
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
	at com.mysql.jdbc.Util.getInstance(Util.java:381)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1031)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2022)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1940)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1925)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:788)
	... 33 more
Pour information,

adresse est le nom de ma base de données.Je n'ai pas de table sequence et je

me suis renseigne c'est pour la génération de clé primaire apparament,

l'objet sequence est utilisé que

sur des bases oracles.Voila quelqu'un pourrait il m'aider

merci.