-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: query.iterate() return an endless Iterator
PostPosted: Fri Jul 08, 2005 4:15 am 
Regular
Regular

Joined: Fri Nov 07, 2003 6:31 am
Posts: 104
Location: Beijing, China
Hi,

I've a problem with a query.iterate() method.

This used to work before I migrated to Hibernate3.0.5:

HQL Query:
Code:
select Profession.id, Profession.professionLibelleApe,  clazz.tauxCotisationAnneeSalariale,  Profession.professionEtatActivation,  Profession.professionDateSuppression   from clazz in class org.xx.common.model.profession.TauxCotisation  left join clazz.tauxCotisationProfessionCodeApeFk as Profession  where (( Profession.professionLibelleApe like '%%' )) AND ((clazz.tauxCotisationAnneeSalariale like '%' ) )  AND ((Profession.id like '%' ) ) AND ((Profession.professionEtatActivation like '1' ))  GROUP BY Profession.id, Profession.professionLibelleApe, clazz.tauxCotisationAnneeSalariale, Profession.professionEtatActivation, Profession.professionDateSuppression ORDER BY Profession.id


I simply iterate over the iterator received from the query:
Code:
while (iter.hasNext()) {
            totalResults += 1;
            log.debug(String.valueOf(totalResults));
        }


It iterate over 100000 times (I actually have to kill the app) whereas the query produce only 146 rows:

The SQL query, returns 146 rows when manually executed on the DB:
Code:
select profession1_.PROFESSION_CODE_APE as col_0_0_, profession1_.PROFESSION_LIBELLE_APE as col_1_0_, tauxcotisa0_.TAUX_COTISATION_ANNEE_SALARIALE as col_2_0_, profession1_.PROFESSION_ETAT_ACTIVATION as col_3_0_, profession1_.PROFESSION_DATE_SUPPRESSION as col_4_0_ from TAUX_COTISATION tauxcotisa0_ left outer join PROFESSION profession1_ on tauxcotisa0_.TAUX_COTISATION_PROFESSION_CODE_APE_FK=profession1_.PROFESSION_CODE_APE where (profession1_.PROFESSION_LIBELLE_APE like '%%') and (tauxcotisa0_.TAUX_COTISATION_ANNEE_SALARIALE like '%') and (profession1_.PROFESSION_CODE_APE like '%') and (profession1_.PROFESSION_ETAT_ACTIVATION like '1') group by profession1_.PROFESSION_CODE_APE , profession1_.PROFESSION_LIBELLE_APE , tauxcotisa0_.TAUX_COTISATION_ANNEE_SALARIALE , profession1_.PROFESSION_ETAT_ACTIVATION , profession1_.PROFESSION_DATE_SUPPRESSION order by profession1_.PROFESSION_CODE_APE



The mapping, not migrated to the Hibernate3 stds:
Code:
<class name="org.xx.common.model.profession.Profession" table="PROFESSION" lazy="true">
        <meta attribute="extends" inherit="false">org.xx.common.persistence.BusinessObject</meta>
        <cache usage="read-write"/>

        <id column="PROFESSION_CODE_APE" name="id" type="java.lang.String">
            <generator class="assigned"/>
        </id>

        <property name="professionLibelleApe" column="PROFESSION_LIBELLE_APE" type="java.lang.String"/>
        <property name="professionDateAccord" column="PROFESSION_DATE_ACCORD" type="java.util.Date"/>
        <property name="professionDateExtension" column="PROFESSION_DATE_EXTENSION" type="java.util.Date"/>
        <property name="professionCodeCcn1" column="PROFESSION_CODE_CCN1" type="java.lang.String"/>
        <property name="professionLibelleCcn1" column="PROFESSION_LIBELLE_CCN1" type="java.lang.String"/>
        <property name="professionCodeCcn2" column="PROFESSION_CODE_CCN2" type="java.lang.String"/>
        <property name="professionLibelleCcn2" column="PROFESSION_LIBELLE_CCN2" type="java.lang.String"/>
        <property name="professionEtatAssujettissementTva" column="PROFESSION_ETAT_ASSUJETTISSEMENT_TVA" type="java.lang.Byte"/>
        <property name="professionNomAdherentNormalise" column="PROFESSION_NOM_ADHERENT_NORMALISE" type="java.lang.String"/>
        <property name="professionDateCreation" column="PROFESSION_DATE_CREATION" type="java.util.Date"/>
        <property name="professionDateMaj" column="PROFESSION_DATE_MAJ" type="java.util.Date"/>
        <property name="professionDateSuppression" column="PROFESSION_DATE_SUPPRESSION" type="java.util.Date"/>
        <property name="professionEtatActivation" column="PROFESSION_ETAT_ACTIVATION" type="java.lang.Byte"/>

        <many-to-one column="PROFESSION_REGROUPEMENT_PROFESSION_CODE_FK1" name="professionRegroupementProfessionCodeFk1" class="org.xx.common.model.profession.RegroupementProfession" outer-join="false"/>
        <many-to-one column="PROFESSION_REGROUPEMENT_PROFESSION_CODE_FK2" name="professionRegroupementProfessionCodeFk2" class="org.xx.common.model.profession.RegroupementProfession" outer-join="false"/>
        <many-to-one column="PROFESSION_CODE_RISQUE_NON_VERSEMENT_CODE_FK" name="professionCodeRisqueNonVersementCodeFk" class="org.xx.common.model.profession.CodeRisqueNonVersement" outer-join="false"/>
        <many-to-one column="PROFESSION_ORGANISME_TIERS_COLLECTEUR_CODE_FK" name="professionOrganismeTiersCollecteurCodeFk" class="org.xx.common.model.profession.OrganismeTiersCollecteur" outer-join="false"/>
        <many-to-one column="PROFESSION_UTILISATEUR_CODE_FK" name="professionUserCodeFk" class="org.xx.common.model.user.User" not-null="true"/>

        <set name="tauxCotisations" inverse="true" cascade="none" lazy="true" outer-join="auto">
            <key column="TAUX_COTISATION_PROFESSION_CODE_APE_FK"/>
            <one-to-many class="org.xx.common.model.profession.TauxCotisation"/>
        </set>

    </class>

<class name="org.xx.common.model.profession.TauxCotisation" table="TAUX_COTISATION" mutable="true" lazy="true">
        <meta attribute="extends" inherit="false">org.xx.common.persistence.BusinessObject</meta>
        <cache usage="read-write"/>

        <id name="id" column="TAUX_COTISATION_ID" type="java.lang.Long">
            <generator class="identity"/>

        </id>

        <property name="tauxCotisationAnneeSalariale" column="TAUX_COTISATION_ANNEE_SALARIALE" type="java.lang.Short" not-null="true"/>
        <property name="tauxCotisationEffectifInf" column="TAUX_COTISATION_EFFECTIF_INF" type="java.lang.Short" not-null="true"/>
        <property name="tauxCotisationEffectifSup" column="TAUX_COTISATION_EFFECTIF_SUP" type="java.lang.Short" not-null="true"/>
        <property name="tauxCotisationTaux" column="TAUX_COTISATION_TAUX" type="java.lang.Double" not-null="true"/>
        <property name="tauxCotisationFraisGestion" column="TAUX_COTISATION_FRAIS_GESTION" type="java.lang.Double" not-null="true"/>
        <property name="tauxCotisationAccompte" column="TAUX_COTISATION_ACCOMPTE" type="java.lang.Double"/>
        <property name="tauxCotisationMontantMin" column="TAUX_COTISATION_MONTANT_MIN" type="java.lang.Double"/>
        <property name="tauxCotisationDateCreation" column="TAUX_COTISATION_DATE_CREATION" type="java.util.Date" not-null="true"/>
        <property name="tauxCotisationDateMaj" column="TAUX_COTISATION_DATE_MAJ" type="java.util.Date" not-null="true"/>

        <many-to-one column="TAUX_COTISATION_PROFESSION_CODE_APE_FK" name="tauxCotisationProfessionCodeApeFk" class="org.xx.common.model.profession.Profession" not-null="true"/>
        <many-to-one column="TAUX_COTISATION_ENVELOPPE_CODE_FK" name="tauxCotisationEnveloppeCodeFk" class="org.xx.common.model.profession.Enveloppe" outer-join="false"/>
        <many-to-one column="TAUX_COTISATION_UTILISATEUR_CODE_FK" name="tauxCotisationUserCodeFk" class="org.xx.common.model.user.User"/>

    </class>


I assume I can easily find a turnaround, but this is still pretty weird.
It seems that the 'nextResult' in the iterator is always the same.

cheers,

_________________
/nodje


Last edited by nodje on Tue Jun 03, 2008 5:10 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 5:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
dude! you dont call iter.next() in your loop - no way that worked anywhere before

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 5:50 am 
Regular
Regular

Joined: Fri Nov 07, 2003 6:31 am
Posts: 104
Location: Beijing, China
I'm never calling .next(), I'm just testing on
while (iter.hasnext()) as indicated above.

You scared me man.

_________________
/nodje


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 5:53 am 
Regular
Regular

Joined: Fri Nov 07, 2003 6:31 am
Posts: 104
Location: Beijing, China
Let's just forget completely what I just wrote...

Soooo sorry

_________________
/nodje


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.