i tried
- Oracle 9i or 10g
- Hibernate 3.2.3
- jdk 1.5
- tomcat 5.5
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="cs.chequerose.beans">
<class name="FeedbackLetter" table="FEEDBACKLETTER">
<id name="id" column="IDFEEDBACKLETTER">
<generator class="increment"/>
</id>
<property column="ID_COMPTE" name="idCompte"/>
<property column="IMMATNO" name="immatNo"/>
<!-- <property column="LETTER_CONTENT" name="letterContent"/>-->
<property column="LETTER_CONTENT2" type="clob" name="letterContent"/>
<property column="LETTER_DATE" name="date"/>
<property column="USERNAME" name="username"/>
</class>
</hibernate-mapping>
bean i try to map (letterContent can be more than 4000 caracters long)
Code:
package cs.chequerose.beans;
import java.util.Date;
/**
* Lettre de relance intermediaire (historisée)
* @author Inf15
*
*/
public class FeedbackLetter {
public FeedbackLetter() {
super();
}
/**
* id de la lettre
*/
private Integer id;
/**
* id compte de l'adhérent auquel la lettre est adressée
*/
private Integer idCompte;
/**
* immatNo du compte auquel la lettre est adressée
*/
private String immatNo;
/**
* XML du contenu
*/
private String letterContent;
/**
* date d'edition de la lettre
*/
private Date date;
/**
* login de l'utilisateur ayant lancé l'édition
*/
private String username;
public FeedbackLetter(Integer idCompte, String immatNo, String letterContent, Date date, String username) {
super();
this.idCompte = idCompte;
this.immatNo = immatNo;
this.letterContent = letterContent;
this.date = date;
this.username = username;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getIdCompte() {
return idCompte;
}
public void setIdCompte(Integer idCompte) {
this.idCompte = idCompte;
}
public String getImmatNo() {
return immatNo;
}
public void setImmatNo(String immatNo) {
this.immatNo = immatNo;
}
public String getLetterContent() {
return letterContent;
}
public void setLetterContent(String letterContent) {
this.letterContent = letterContent;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
but when i try to insert
Code:
Session session = getSessionFactory().openSession();
Transaction tx = session.beginTransaction();
//creation objet feedbackletter avant envoi
FeedbackLetter newLetter = new FeedbackLetter(idCompte,"test",generateXmlFeedbackLetter(pIdCompte),new java.util.Date(),"invite");
//sauvegarde en bdd oracle par hibernate
session.save(newLetter);
tx.commit();
session.close();
i get
Code:
Etat HTTP 500 -
type Rapport d'exception
message
description Le serveur a rencontré une erreur interne () qui l'a empêché de satisfaire la requête.
exception
javax.servlet.ServletException: java.lang.String
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:508)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:415)
cs.chequerose.ihmactions.requestProcessor.CRappRequestProcessor.processActionPerform(CRappRequestProcessor.java:70)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:225)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:446)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
cause mère
java.lang.ClassCastException: java.lang.String
org.hibernate.type.ClobType.set(ClobType.java:50)
org.hibernate.type.ClobType.nullSafeSet(ClobType.java:118)
org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:1997)
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2243)
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:52)
org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
cs.chequerose.edition.FeedbackLetterGenerator.sendLetter(FeedbackLetterGenerator.java:601)
cs.chequerose.ihmactions.SendLetter.execute(SendLetter.java:42)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:413)
cs.chequerose.ihmactions.requestProcessor.CRappRequestProcessor.processActionPerform(CRappRequestProcessor.java:70)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:225)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:446)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note La trace complète de la cause mère de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/5.5.20.
Apache Tomcat/5.5.20
"
bean
sorry for french comments ;)