java.sql.BatchUpdateException: Column 'customerOrderId' cannot be null
salut tous le monde,
Je suis entrain d'implémenter une page admin dont une des fonctionamlités est de supprimer un client.
Malheureusement je reçois l'erreur suivante:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| contact3 >> 15:59:51,559 ERROR [JDBCExceptionReporter] Column 'customerOrderId' cannot be null
contact3 >> 15:59:51,561 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:92)
......
Caused by: java.sql.BatchUpdateException: Column 'customerOrderId' cannot be null
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1237)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:936)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 74 more
contact3 >> 15:59:51,567 ERROR [SeamPhaseListener] uncaught exception
java.lang.IllegalStateException: Could not commit transaction
at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:602)
at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:330) |
le backing bean ou j'ai implémenter la méthode de suppressuin client est la suivante:
Code:
1 2 3 4 5 6 7 8 9
|
public void deleteCustomer() {
Long customId = (Long) em.createQuery("select c.customerId from Customer c where c.customerId =:customerId")
.setParameter("customerId", customerId)
.getSingleResult();
Customer custom = (Customer) em.find(Customer.class, customId);
em.remove(custom);
} |
ma page .xhtml est
Code:
1 2 3 4 5 6 7 8 9
| <a4j:outputPanel id="deleteCustomer" rendered="false" binding="#{deleteCustomer}">
<h:selectOneMenu id="deleteClients" converter="javax.faces.Long" value="#{customerId}" required="true" rendered="true">
<s:selectItems id="deleteCustomers" value="#{customers}" var="cust" label="#{cust.companyName}" itemValue="#{cust.customerId}"
noSelectionLabel="#{messages['selectCustomer']}"/>
</h:selectOneMenu><br/>
<h:commandButton id="delete" type="submit" value="#{messages['deleteCustomer']}" action="#{adminAction.deleteCustomer()}" immediate="true"/>
<h:commandButton type="submit" value="#{messages['cancel']}" action="#{adminAction.hideDeleteCustomer()}"/>
</a4j:outputPanel> |
je comprend pas l'erreur d'où elle vient pourtant que l'insertion marche nikel. Je vous informe aussi que la req. implémenté au sein de la méthode retourne bien l'objet selectionné dans la page .xhtml
quelq'un a une idée??
merci