Bonjour,


Je n'arrive pas avec hibernate à insérer dans une table contenant une clé primaire non null:

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
78
[17/05/04 23:01:45:481 CEST]  a6744b2 JDBCException W net.sf.hibernate.util.JDBCExceptionReporter  SQL Error: -10, SQLState: 23000
[17/05/04 23:01:45:491 CEST]  a6744b2 JDBCException E net.sf.hibernate.util.JDBCExceptionReporter  Try to insert null into a non-nullable column: column: ID table: PRODUCTS in statement [insert into products (name, price, amount, id) values (?, ?, ?, null)]
[17/05/04 23:01:45:521 CEST]  a6744b2 JDBCException W net.sf.hibernate.util.JDBCExceptionReporter  SQL Error: -10, SQLState: 23000
[17/05/04 23:01:45:661 CEST]  a6744b2 JDBCException E net.sf.hibernate.util.JDBCExceptionReporter  Try to insert null into a non-nullable column: column: ID table: PRODUCTS in statement [insert into products (name, price, amount, id) values (?, ?, ?, null)]
[17/05/04 23:01:45:721 CEST]  a6744b2 JDBCException E net.sf.hibernate.util.JDBCExceptionReporter  could not insert: [hibernate.test.Products]
[17/05/04 23:01:45:751 CEST]  a6744b2 JDBCException E net.sf.hibernate.util.JDBCExceptionReporter  TRAS0014I: L'exception suivante a été consignée : java.sql.SQLException: Try to insert null into a non-nullable column: column: ID table: PRODUCTS in statement [insert into products (name, price, amount, id) values (?, ?, ?, null)]
	at org.hsqldb.jdbcDriver.throwError(Unknown Source)
	at org.hsqldb.jdbcPreparedStatement.executeUpdate(Unknown Source)
	at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:527)
	at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
	at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
	at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:906)
	at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:839)
	at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:757)
	at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:720)
	at hibernate.test.ProductsAction.execute(ProductsAction.java:239)
	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
	at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
	at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
	at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
	at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
	at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
	at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
	at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:948)
	at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)
	at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)
	at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
	at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)
	at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
	at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
	at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
	at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
	at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)
	at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:435)
	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
.
                                 java.sql.SQLException: Try to insert null into a non-nullable column: column: ID table: PRODUCTS in statement [insert into products (name, price, amount, id) values (?, ?, ?, null)]
	at org.hsqldb.jdbcDriver.throwError(Unknown Source)
	at org.hsqldb.jdbcPreparedStatement.executeUpdate(Unknown Source)
	at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:527)
	at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
	at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
	at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:906)
	at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:839)
	at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:757)
	at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:720)
	at hibernate.test.ProductsAction.execute(ProductsAction.java:239)
	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
	at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
	at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
	at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
	at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
	at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
	at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
	at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:948)
	at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)
	at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)
	at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
	at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)
	at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
	at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
	at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
	at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
	at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)
	at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:435)
	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)

Merci