-->
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.  [ 3 posts ] 
Author Message
 Post subject: Getting the Size of a Collection(List) with a Criteria Query
PostPosted: Sun Jan 16, 2005 4:12 pm 
Newbie

Joined: Sun Jan 16, 2005 3:47 pm
Posts: 2
Hi,
i'd like to know if it's possible (or better how) i can create a Criteria,
where i can select a List of "Reisepaket" where the size of the List
"events" is equal 'x' (e.g. x = 0).

I searched Documentation and Forum here, but couldn't find any
hint.

Greets,
ap0

Hibernate version: 2.1.7c

Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping package="de.fh_brs.travelution.businessobjects">
    <class name="Reisepaket" table="reisepaket">
        <id name="id" type="long" column="paket_id">
           <generator class="identity"/>
      </id>
        <component name="reisewunsch" class="Reisewunsch">
         <property name="ziel" type="string" not-null="true"/>
         <property name="anfang" type="date" not-null="true"/>
         <property name="ende" type="date" not-null="true"/>
         <property name="beschreibung" type="text"/>
        </component>
        <many-to-one name="kunde" class="Kunde" not-null="true"/>
        <many-to-one name="agent" class="Agent"/>
      <many-to-one name="transfer" class="Transfer"/>
        <list name="events">
         <key column="events"/>
         <index column="pos_events"/>
         <composite-element class="Event"/>       
      </list>
      <property name="istGebucht" type="true_false" not-null="true"/>
    </class>   
</hibernate-mapping>


Name and version of the database you are using:
MySQL 4.0.20a


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 17, 2005 1:10 pm 
Regular
Regular

Joined: Tue Jun 22, 2004 8:01 pm
Posts: 106
Location: PowderTown, Utah, USA
Keep in mind that sometimes things are just easier in HQL. I try to use the criteria API where I can (I just like it better than having HQL embedded in my code... personal choice here!). In spite of that i find that sometimes for something simple it's just easier to haul off and do a "select count(*) from MyObject" in HQL.

I realize that this doesn't really help answer your question. But I do find it helps to simply give yourself permission to go ahead and use HQL in places where it makes sense.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 10:19 am 
Newbie

Joined: Sun Jan 16, 2005 3:47 pm
Posts: 2
i didn't find a way how to solve this easy, so i changed the Java a bit to
handle with Criteria and HQL. With HQL ist was very easy to get the size
of my List.


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