thanks for your response,
the code of DAO class is bellow
Code:
package istia.st.springmvc.personnes.dao;
import istia.st.springmvc.personnes.entites.Personne;
import istia.st.springmvc.personnes.hibernate.HibernateUtil;
import istia.st.springmvc.personnes.hibernate.Personnes;
import istia.st.springmvc.personnes.utils.SpringUtils;
import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.springframework.orm.hibernate.support.HibernateDaoSupport;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
public class DaoImplCommon extends HibernateDaoSupport implements
IDao {
// configuration: parametres + mapping
public Configuration config = null;
// Usine à fabriquer des sessions
public SessionFactory factory = null;
// liste des personnes
public List getAll() {
return getHibernateTemplate().find(
"from Personnes ");
}
// obtenir une personne en particulier
public Personnes getOne(int id) {
// on la récupère dans la BD
try
{
if ((Integer)id != null)
{
List r = getHibernateTemplate().find(
"from Personnes where id = "+id);
if (r.size() == 0)
{
return null;
}
else
{
return (Personnes) r.get(0);
}
}
return null;
}
catch (HibernateObjectRetrievalFailureException e)
{
return null;
}
}
// suppression d'une personne
public void deleteOne(int id) {
// on supprime la personne
/*int n = getSqlMapClientTemplate().delete("Personne.deleteOne",
new Integer(id));
// a-t-on réussi
if (n == 0) {
throw new DaoException("Personne d'id [" + id + "] inconnue", 2);
}*/
}
// ajouter ou modifier une personne
public void saveOne(Personnes personne) {
// le paramètre personne est-il valide ?
check(personne);
// ajout ou modification ?
if (personne.getId() == -1) {
// ajout
insertPersonne(personne);
} else {
updatePersonne(personne);
}
}
// ajouter une personne
protected void insertPersonne(Personnes personne) {
// 1ère version
personne.setVersion(1);
getHibernateTemplate().save(personne);
}
// modifier une personne
protected void updatePersonne(Personnes personne) {
// on attend 10 ms - pour les tests mettre true au lieu de false
//getHibernateTemplate().update(personne);
}
// vérification validité d'une personne
private void check(Personnes p) {
// personne p
if (p == null) {
throw new DaoException("Personne null", 10);
}
// id
if (p.getId() != -1 && p.getId() < 0) {
throw new DaoException("Id [" + p.getId() + "] invalide", 11);
}
// date de naissance
if (p.getDatenaissance() == null) {
throw new DaoException("Date de naissance manquante", 12);
}
// nombre d'enfants
if (p.getNbenfants() < 0) {
throw new DaoException("Nombre d'enfants [" + p.getNbenfants()
+ "] invalide", 13);
}
// nom
if (p.getNom() == null || p.getNom().trim().length() == 0) {
throw new DaoException("Nom manquant", 14);
}
// prénom
if (p.getPrenom() == null || p.getPrenom().trim().length() == 0) {
throw new DaoException("Prénom manquant", 15);
}
}
// attente
private void wait(int N) {
// on attend N ms
try {
Thread.sleep(N);
} catch (InterruptedException e) {
// on affiche la trace de l'exception
e.printStackTrace();
return;
}
}
}
and the IDAO interface is
Code:
package istia.st.springmvc.personnes.dao;
import istia.st.springmvc.personnes.entites.Personne;
import istia.st.springmvc.personnes.hibernate.Personnes;
import java.util.Collection;
import java.util.List;
public interface IDao {
// liste de toutes les personnes
List getAll();
// obtenir une personne particulière
Personnes getOne(int id);
// ajouter/modifier une personne
void saveOne(Personnes personne);
// supprimer une personne
void deleteOne(int id);
}
I checked everywhere if there is a use of packages starting by net.sf (hibernate2), the only place where they are it is in the files of configurantion of middlegen, that I used to generate the mapping files
the code of this file
Code:
<?xml version="1.0" encoding="utf-8"?>
<!--
This build file is generated by MiddlegenIDE.
MiddlegenIDE: http://ultimania.org/middlegenide/
-->
<project name="Middlegen Hibernate" default="compile" basedir="../.">
<property file=".././build.properties"/>
<property name="hibernate.cascade" value="all" />
<property name="package" value="org.ultimania.model" />
<property name="gen.xdoclet-tag" value="false" />
<property name="gui" value="true" />
<property name="jdbc.jar" value="C:\Documents and Settings\jamal\Mes documents\Appli\springmvc4-code\mvc-37\lib\mysql-connector-java-3.1.9-bin.jar" />
<property name="database.driver" value="com.mysql.jdbc.Driver" />
<property name="lib.dir" value="/C:/Documents and Settings/jamal/Mes documents/LOGICIELS/wtp-all-in-one-sdk-R-1.5.0-200606281455-win32/eclipse/plugins/net.sf.middlegen_2.1.91/lib/" />
<property name="database.url" value="jdbc:mysql://localhost/dbpersonnes" />
<property name="database.userid" value="root" />
<property name="database.password" value="" />
<property name="database.schema" value="" />
<property name="database.catalog" value="" />
<property name="dest.dir" value="WEB-INF/src" />
<target name="init" depends="prepare,fail-if-no-middlegen,fail-if-no-hibernate,fail-if-no-hibernate-ext">
<taskdef
name="middlegen"
classname="middlegen.MiddlegenTask"
classpathref="middlegen.classpath"
/>
<taskdef
name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="hibernate-ext.classpath"
/>
<mkdir dir="${dest.dir}"/>
</target>
<target name="prepare">
<path id="middlegen.classpath">
<pathelement path="${jdbc.jar}"/>
<fileset dir="${lib.dir}" includes="*.jar"/>
</path>
<path id="hibernate-ext.classpath">
<fileset dir="${lib.dir}" includes="*.jar"/>
</path>
<available property="middlegen" classname="middlegen.MiddlegenTask" classpathref="middlegen.classpath"/>
<available property="hibernate" classname="net.sf.hibernate.Hibernate" classpathref="hibernate-ext.classpath"/>
<available property="hibernate-ext" classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask" classpathref="hibernate-ext.classpath"/>
</target>
<target name="fail-if-no-middlegen" unless="middlegen">
<fail>
Middlegen is not found. Please install Middlegen.
</fail>
</target>
<target name="fail-if-no-hibernate" unless="hibernate">
<fail>
Hibernate is not found. Please install Hibernate.
</fail>
</target>
<target name="fail-if-no-hibernate-ext" unless="hibernate-ext">
<fail>
Hibernate-Extension is not found. Please install Hibernate-Extenstion.
</fail>
</target>
<target name="gen-hbm" depends="init">
<middlegen
appname="org.ultimania.model"
prefsdir="."
gui="${gui}"
databaseurl="${database.url}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema="${database.schema}"
catalog="${database.catalog}"
>
<hibernate
version="3.0"
destination="${dest.dir}"
package="${package}"
genXDocletTags="${gen.xdoclet-tag}"
standardCascade="${hibernate.cascade}"
javaTypeMapper="middlegen.plugins.hibernate.HibernateJavaTypeMapper"
/>
<table name="personnes" />
</middlegen>
</target>
<target name="gen-java" depends="gen-hbm">
<hbm2java output="${dest.dir}">
<fileset dir="${dest.dir}">
<include name="**/*.hbm.xml" />
</fileset>
</hbm2java>
</target>
<target name="compile" depends="gen-java">
</target>
</project>
thanks