Hello, i have a problem with the getHibernateTemplate().get(...) Method.
Here is my mapping :
My object FournisseurImpl implements an interface named Fournisseur so I can make HQL on the interface (see below the working code using Criteria)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> <class name="com.auchan.protoFwk27.metier.fournisseur.internal.FournisseurImpl" table="P2_5_FOURNISSEUR"> <id column="IFLS" name="ifls"> <generator class="assigned"/> </id> <property column="LIBELLE" name="libelle" not-null="true"/> </class> </hibernate-mapping>
Here is what i try to do :
i throw me :Code:Fournisseur fournisseur = (Fournisseur) getHibernateTemplate().get(Fournisseur.class, idFournisseur);
this code works :Code:org.hibernate.MappingException: Unknown entity: com.auchan.protoFwk27.metier.fournisseur.Fournisseur
Other code working :Code://Use of Criteria List myList = null; DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Fournisseur.class); detachedCriteria.add(Restrictions.eq("ifls", idFournisseur)); myList = getHibernateTemplate().findByCriteria(detachedCriteria); Fournisseur fournisseur = (Fournisseur) myList.get(0);
I don't understand why the getHibernateTemplate().get(...) does not work. May be it's normal ???Code:List lstFrn = getHibernateTemplate().loadAll(Fournisseur.class);


Reply With Quote
