-->
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: Criteria API and map with entity as key
PostPosted: Thu Aug 05, 2004 2:21 am 
Newbie

Joined: Thu Aug 05, 2004 1:54 am
Posts: 10
Location: Novosibirsk, Russia
I have with a map with an entity as index. Here's an excerpt from mapping:
Code:
    <class name="com.fis.om.Pipeline">
        <id column="id" name="id">
            <generator class="native" />
        </id>

        <map
            name="employees"
            lazy="false"
        >
            <key column="pipeline" />
            <index-many-to-many
                column="role"
                class="com.fis.om.Role"
            />
            <many-to-many
                column="pipelineAssoc"
                class="com.fis.om.Employee"
            />
        </map>
    </class>

    <class name="com.fis.om.PipelineStage">
        <id column="id" name="id">
            <generator class="native" />
        </id>

        <property name="name" />
        <many-to-one name="responsible" class="com.fis.om.Role" />
    </class>

        <subclass
            name="com.fis.om.Company"
            discriminator-value="13"
        >
            <many-to-one name="stage" class="com.fis.om.PipelineStage" />
            <many-to-one name="pipeline" class="com.fis.om.Pipeline" />

   </subclass>

I want to make a Criteria query against Company. In HQL it would be ( not a real query, just a part related to the "employees" association ):

SELECT c FROM Company AS c WHERE c.pipeline.employees[ c.stage.responsible ].id = ?

What's the good way to do it with Criteria API?

Using Hibernate 2.1.4
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 11:41 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
Chapter 12. Criteria Queries of reference documentation:
Quote:
...For now, this API is less powerful and than the more mature HQL query facilities

So, use HQL :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 06, 2004 1:04 am 
Newbie

Joined: Thu Aug 05, 2004 1:54 am
Posts: 10
Location: Novosibirsk, Russia
shl wrote:
Chapter 12. Criteria Queries of reference documentation:
Quote:
...For now, this API is less powerful and than the more mature HQL query facilities

So, use HQL :)


I create queries dynamically and composing query from HQL string pieces isn't a very nice thing to do. But seems like I'll have to do it :(


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.