i got this kinf of class,
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class lazy="true" name="ortec.oea.bl.model.metiers.iso.commandes.CommandeIso" table="ISO_COM" >
<id name="id" column="ISO_COM_ID" type="long" unsaved-value="0">
<generator class="sequence">
<param name="sequence">ISO_COM_SEQ</param>
</generator>
</id>
<many-to-one name="chantier" column="CHANTIER_ID" />
<many-to-one name="agence" column="STRUCTURE_ID" />
<many-to-one name="commandeFournisseur" column="COMMANDE_ID" />
<many-to-one name="fournisseur" column="FOURNISSEUR_ID" />
<many-to-one name="site" column="FOU_SITE_ID" />
<property name="fournisseurNom" column="FOURNISSEUR_NOM" />
<property name="siteNom" column="SITE_NOM" />
<property name="numero" column="COMMANDE" />
<property name="date" column="DATE_COMMANDE" />
<property name="solde" column="SOLDE" type="yes_no" />
</class>
</hibernate-mapping>
when i load an object using
CommandeIso o = (CommandeIso) new DAOService().loadObject(CommandeIso.class, 19);
in deep the service use an session.load(clazz, id);
everetnig are ok because the object is proxyfied by javaassist, and the class name is like
CommandeIso_$$_javassist_26.
when i use the Hibenate Query Object using
Code:
q = Tools.stringFormat("from {0} o where o.chantier.id=?",CommandeIso.class.getName());
l = new DAOService().findObjects(q, new Long(7), 0, 2);
where find object use the list method of the Query object
Code:
public List findObjects(String query, Object[] parameters, int firstresult, int maxresult) throws ServiceException{
List rs=null;
long timeStart = System.currentTimeMillis();
try {
Session se = HibernateListener.currentSession();
Query q = se.createQuery(query);
if (firstresult >=0){
q.setFirstResult(firstresult);
}
if (maxresult >=0){
q.setMaxResults(maxresult);
}
// positionne les paramétres
// -------------------------
if (parameters!=null) {
for (int i=0; i<parameters.length;i++){
q.setParameter(i, parameters[i]);
}
}
rs = q.list();