Could not execute JDBC batch update
salut tous le monde, je suis nouveau avec hibernate, jai une table qui a une clé composé,j utilise myeclipse.
voici le script de la table généré avec oracle:
Code:
1 2 3 4 5 6 7 8
|
CREATE TABLE "ISIFINUSER"."PHASE_ETAPE" ("ID_PROJ" NUMBER(2) NOT
NULL, "ID_ETAPE" NUMBER(2) NOT NULL, "DATE" VARCHAR2(25 byte)
NOT NULL, "DATE_DEB_ETAPE" VARCHAR2(25 byte) NOT NULL,
"DATE_FIN_ETAPE" VARCHAR2(25 byte) NOT NULL, "COMMENT_ETAPE"
VARCHAR2(1000 byte) NOT NULL,
CONSTRAINT "PHASE_ETAPE_PK" PRIMARY KEY("ID_PROJ", "ID_ETAPE",
"DATE") |
j ai mappé cette table et jai le fichier de mapping suivant:
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
|
<hibernate-mapping>
<class name="com.isifin.hiber.PhaseEtape" table="PHASE_ETAPE" schema="ISIFINUSER">
<composite-id name="id" class="com.isifin.hiber.PhaseEtapeId">
<key-property name="idProj" type="java.lang.Long">
<column name="ID_PROJ" precision="2" scale="0" />
</key-property>
<key-property name="idEtape" type="java.lang.Long">
<column name="ID_ETAPE" precision="2" scale="0" />
</key-property>
<key-property name="date" type="java.lang.String">
<column name="DATE" length="25" />
</key-property>
</composite-id>
<property name="dateDebEtape" type="java.lang.String">
<column name="DATE_DEB_ETAPE" length="25" />
</property>
<property name="dateFinEtape" type="java.lang.String">
<column name="DATE_FIN_ETAPE" length="25" />
</property>
<property name="commentEtape" type="java.lang.String">
<column name="COMMENT_ETAPE" length="1000" />
</property>
</class>
</hibernate-mapping> |
il ya deux class java resultantes: la classe de l identifiant et la class PhaseTache
voici le code des deux class:
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
|
ublic class PhaseEtapeId implements java.io.Serializable {
// Fields
private Long idProj;
private Long idEtape;
private String date;
// Constructors
/** default constructor */
public PhaseEtapeId() {
}
/** full constructor */
public PhaseEtapeId(Long idProj, Long idEtape, String date) {
this.idProj = idProj;
this.idEtape = idEtape;
this.date = date;
}
// Property accessors
public Long getIdProj() {
return this.idProj;
}
public void setIdProj(Long idProj) {
this.idProj = idProj;
}
public Long getIdEtape() {
return this.idEtape;
}
public void setIdEtape(Long idEtape) {
this.idEtape = idEtape;
}
public String getDate() {
return this.date;
}
public void setDate(String date) {
this.date = date;
}
public boolean equals(Object other) {
if ((this == other))
return true;
if ((other == null))
return false;
if (!(other instanceof PhaseEtapeId))
return false;
PhaseEtapeId castOther = (PhaseEtapeId) other;
return ((this.getIdProj() == castOther.getIdProj()) || (this
.getIdProj() != null
&& castOther.getIdProj() != null && this.getIdProj().equals(
castOther.getIdProj())))
&& ((this.getIdEtape() == castOther.getIdEtape()) || (this
.getIdEtape() != null
&& castOther.getIdEtape() != null && this.getIdEtape()
.equals(castOther.getIdEtape())))
&& ((this.getDate() == castOther.getDate()) || (this.getDate() != null
&& castOther.getDate() != null && this.getDate()
.equals(castOther.getDate())));
}
public int hashCode() {
int result = 17;
result = 37 * result
+ (getIdProj() == null ? 0 : this.getIdProj().hashCode());
result = 37 * result
+ (getIdEtape() == null ? 0 : this.getIdEtape().hashCode());
result = 37 * result
+ (getDate() == null ? 0 : this.getDate().hashCode());
return result;
}
} |
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
|
public class PhaseEtape implements java.io.Serializable {
// Fields
private PhaseEtapeId id;
private String dateDebEtape;
private String dateFinEtape;
private String commentEtape;
// Constructors
/** default constructor */
public PhaseEtape() {
}
/** full constructor */
public PhaseEtape(PhaseEtapeId id, String dateDebEtape,
String dateFinEtape, String commentEtape) {
this.id = id;
this.dateDebEtape = dateDebEtape;
this.dateFinEtape = dateFinEtape;
this.commentEtape = commentEtape;
}
// Property accessors
public PhaseEtapeId getId() {
return this.id;
}
public void setId(PhaseEtapeId id) {
this.id = id;
}
public String getDateDebEtape() {
return this.dateDebEtape;
}
public void setDateDebEtape(String dateDebEtape) {
this.dateDebEtape = dateDebEtape;
}
public String getDateFinEtape() {
return this.dateFinEtape;
}
public void setDateFinEtape(String dateFinEtape) {
this.dateFinEtape = dateFinEtape;
}
public String getCommentEtape() {
return this.commentEtape;
}
public void setCommentEtape(String commentEtape) {
this.commentEtape = commentEtape;
}
} |
MyEclipse génére aussi des class utilitaire PhaseTacheDAO qui posséde une methode save();
le probléme est que quand jessay de sauvegarder un nouvel objet avec le code suivant:
Code:
1 2 3 4 5 6 7 8 9
|
PhaseEtapeId phaseEtapeId=new PhaseEtapeId(Long.getLong("1"),Long.getLong(afficherFormulaireForm.getId_etape()),stDate);
PhaseEtape phaseEtape=new PhaseEtape(phaseEtapeId,afficherFormulaireForm.getDate_deb_etape(),afficherFormulaireForm.getDate_fin_etape(),afficherFormulaireForm.getComment());
PhaseEtapeDAO phaseEtapeDAO=new PhaseEtapeDAO();
Transaction tx=phaseEtapeDAO.getSession().beginTransaction();
phaseEtapeDAO.save(phaseEtape);
tx.commit();
phaseEtapeDAO.getSession().close(); |
j ai l erreur suivante:
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
|
exception
javax.servlet.ServletException: Could not execute JDBC batch update
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
cause mère
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
com.isifin.struts.action.SauverAction.execute(SauverAction.java:57)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802) |
si quelqu un peut m aider je lui serai tres reconnaissant,
merci davance