-->
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.  [ 2 posts ] 
Author Message
 Post subject: On join, one-to-many collection not populated
PostPosted: Thu Feb 10, 2005 12:49 pm 
Beginner
Beginner

Joined: Tue Jan 11, 2005 5:50 am
Posts: 43
Location: Zurich (Suisse)
Hello

I must have changed something and now I'm not sure why my joins are not working. As an example if I execute the named query as it is down below I get a result of 935 services. But there are only 120 of them, for a certain time range there are 935 abos.

So instead of the services and the populated collection of abos I get a service for each abo, which is not funny :-)

Either I am code blind and do not see what the error is or I utterly misunderstand the join syntax. If someone could help me, I'd greatly appreciate any hints.

Regards
Tarik


Hibernate version:
2

Mapping documents:

Code:
<hibernate-mapping>
   
   <class name="com.someCompany.MMSCAdmin.beans.Service" table="SERVICE" lazy="true" batch-size="20" >
      <cache usage="read-write"/>
      <id name="serviceID" type="long" column="SERVICE_ID">
         <generator class="assigned"/>
      </id>
      <property name="name" type="java.lang.String" column="NAME" not-null="true" length="100"/>
      <property name="serviceTable" type="java.lang.String" column="SERVICETABLE" not-null="true" length="100"/>
      <!-- Associations -->
      <map name="keywords" lazy="true" sort="natural" order-by="KEYWORD">
         <key column="SERVICE_ID"/>
         <index column="KEYWORD" type="string"/>
         <one-to-many class="com.someCompany.MMSCAdmin.beans.Keyword"/>
      </map>
      <map name="abos"  lazy="true" sort="natural" order-by="SENDDATESTART">
         <key column="SERVICE_ID"/>
         <index column="MMSABO_ID" type="int"/>
         <one-to-many class="com.someCompany.MMSCAdmin.beans.MMSAbo"/>
      </map>
   </class>
   
   <query name="com.someCompany.MMSCAdmin.beans.Service.getAllServicesByAboDates"><![CDATA[
         from com.mobilelogix.MMSCAdmin.beans.Service as service
         left join fetch service.abos as abo   
         where abo.senddateStart >= :senddateStart
         and abo.senddateEnd <= :senddateEnd         
         ]]></query>   
</hibernate-mapping>

hibernate-mapping>
   
   <class name="com.someCompany.MMSCAdmin.beans.MMSAbo" table="MMSABO" lazy="true" batch-size="20" >
      <cache usage="read-write"/>
      <id name="mmsaboID" type="long" column="MMSABO_ID">
         <generator class="assigned"/>
      </id>
      <property name="senddateStart" type="java.util.Date" column="SENDDATESTART" length="19"/>
      <property name="senddateEnd" type="java.util.Date" column="SENDDATEEND" length="19"/>
      <property name="serviceID" type="long" column="SERVICE_ID" not-null="true" length="20"/>
      <property name="composedID" type="long" column="COMPOSED_ID" not-null="true" length="20"/>
      <!-- Associations -->
   </class>   
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

Code:
/**
     * @param abo
     * @return @throws
     *         HibernateException
     */
    public static List getAllServicesByAboDates(MMSAbo abo)
            throws HibernateException {
        Session session = HibernateUtil.currentSession();
        Query query = session
                .getNamedQuery("com.someCompany.MMSCAdmin.beans.Service.getAllServicesByAboDates");
        query.setString("senddateEnd", abo.getSenddateEndAsString());
        query.setString("senddateStart", abo.getSenddateStartAsString());
        query.setCacheable(true);
        return query.list();
    }


Name and version of the database you are using:
MySQL 4.0.16


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 10, 2005 1:02 pm 
Beginner
Beginner

Joined: Tue Jan 11, 2005 5:50 am
Posts: 43
Location: Zurich (Suisse)
Sorry, the collections are populated but I get too many services, looks like a cartesian ... or better said, I do not know so far ...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.