This week's book giveaway is in the Cloud forum.
We're giving away four copies of The Business Blockchain and have William Mougayar on-line!
See this thread for details.
Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HibernateException: Wrong column type: datedebut, expected: date

 
Daoui youssef
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone!

I like to ask if anyone had this problem:

I'm a beginner in struts and hibernate, I'm using as IDE NETBEANS 6.5, Apache Tomcat/6.0.18 as Application Server and MYSQL Server as a Database server, my project works just fine until i wanted to migrate my Database Server to MS SQL SERVER Express, i downloaded the driver and successfully connected Java to MS SQL Server, but when i run my project, and at the loggin action using a class having an attribute of type date, it raise me an error :

///////////////////////////////////////////////////////
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: L'ex�cution de la servlet a lanc� une exception
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)


cause m�re

java.lang.ExceptionInInitializerError
hibernate.HibernateUtil.<clinit>(HibernateUtil.java:31)
application.gestion.GestCompte.tous(GestCompte.java:39)
application.gestion.GestCompte.existe(GestCompte.java:108)
application.struts.form.LoginForm.validate(LoginForm.java:70)
org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:950)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:207)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)


cause m�re

org.hibernate.HibernateException: Wrong column type: datedebut, expected: date
org.hibernate.mapping.Table.validateColumns(Table.java:261)
org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1083)
org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:317)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
hibernate.HibernateUtil.<clinit>(HibernateUtil.java:27)
application.gestion.GestCompte.tous(GestCompte.java:39)
application.gestion.GestCompte.existe(GestCompte.java:108)
application.struts.form.LoginForm.validate(LoginForm.java:70)
org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:950)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:207)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)


note La trace compl�te de la cause m�re de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/6.0.18.

////////////////////////////////////////////////////////////////


The second time i run my project i have this message :

//////////////////////////////////////////////////////
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: L'ex�cution de la servlet a lanc� une exception
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)


cause m�re

java.lang.NoClassDefFoundError: Could not initialize class hibernate.HibernateUtil
application.gestion.GestCompte.tous(GestCompte.java:39)
application.gestion.GestCompte.existe(GestCompte.java:108)
application.struts.form.LoginForm.validate(LoginForm.java:70)
org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:950)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:207)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)


note La trace compl�te de la cause m�re de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/6.0.18.

////////////////////////////////////////////////////////////////////////////////////

My class is :
************************
package application.metier;

import java.util.Date;
import rh.metier.Employee;
import java.util.HashSet;
import java.util.Set;

/**
*
* @author DAOUI Youssef
*/

public class Compte {
private int id;
private Set responsabilites = new HashSet();
private String login;
private String pass;
private Date datedebut;
private Date datefin;
private Employee emp;
private String flag;

public Compte() {
this.flag="O";
}

public int getId() {
return id;
}

public Set getResponsabilites() {
return responsabilites;
}

public String getLogin() {
return login;
}

public String getPass() {
return pass;
}

public Employee getEmp() {
return emp;
}

public String getFlag() {
return flag;
}

public Date getDatedebut() {
return datedebut;
}

public Date getDatefin() {
return datefin;
}

public void setId(int id) {
this.id = id;
}

public void setLogin(String login) {
this.login = login;
}

public void setPass(String pass) {
this.pass = pass;
}

public void setEmp(Employee emp) {
this.emp = emp;
}

public void setFlag(String flag) {
this.flag = flag;
}

public void setResponsabilites(Set responsabilites) {
this.responsabilites = responsabilites;
}

public void setDatedebut(Date datedebut) {
this.datedebut = datedebut;
}

public void setDatefin(Date datefin) {
this.datefin = datefin;
}

@Override
public int hashCode() {
int hash = 0;
hash += (int) id;
return hash;
}

@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Compte)) {
return false;
}
Compte other = (Compte) object;
if (this.id != other.id) {
return false;
}
if (other.getId() == 0) {
return false;
}
return true;
}

@Override
public String toString() {
return "APPLICATION.Utilisateur[id=" + id + "]";
}

}
*****************************
And its mapping file is :
**************************
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false">
<class name="application.metier.Compte" table="BEC_COMPTES">
<id column="compte_id" name="id" type="int">
<generator class="increment"/>
</id>
<many-to-one cascade="save-update,persist" class="rh.metier.Employee" column="emp_id" lazy="false" name="emp"/>
<set cascade="all" name="responsabilites" table="bec_compte_resp">
<key column="compte_id"/>
<many-to-many class="application.metier.Responsabilite" column="resp_id"/>
</set>
<property name="login" type="string"/>
<property name="pass" type="string"/>
<property name="datedebut" type="date"/>
<property name="datefin" type="date"/>
<property name="flag" type="string"/>
</class>
</hibernate-mapping>

/////////////////////////////////////////////:
Any one had an idea to solve this problem?
if anyone have the same problem please reply to make sure that we need an answer if any one knows it.


Thanks in advance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic