-->
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: attaching Criteria to a query instantiation
PostPosted: Wed Aug 31, 2005 2:33 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
Hibernate version:
3.0.5

I'm trying to use the Criteria to override lazy initialization for a query.
Is there a way to add criteria to a query? something starting along the lines of the following code

Code:
               Query query = session.getNamedQuery("fromJobQueueList");
               query.setProperties(jql);

               session.createCriteria(jql.getClass()).setFetchMode("JobQueueSysins", FetchMode.JOIN);



I'm trying to use the criteria because I don't want to have lazy="false" declared for the entire class and I don't want to use Hibernate.initialize because that gets me the whole N+1 problem.

... or am I generating too much trouble for myself and go ahead and just initialize lazy="false" for the class in the hbm file?


Top
 Profile  
 
 Post subject: Re: attaching Criteria to a query instantiation
PostPosted: Wed Aug 31, 2005 2:40 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
You should just code the join in your query.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 31, 2005 4:07 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
awww and I did all that research into criteria.

is there any way to declare an association as not lazy instead of the whole class. I tried the following but it doesn't work. I have to move the lazy="false" up inside the class definition area of the hbm file to get it to work

Code:
    <!-- associations -->
    <!-- uni-directional one-to-many association to JobQueueSysin -->

    <list
        name="jobQueueDetails"
        cascade="all-delete-orphan"
        lazy="true"
        fetch="join"
   outer-join="true"

    >
        <key>
            <column name="instidq" />
             ....
        </key>
        <index column="user_seq_no" />
        <one-to-many
            class="dars.apis.audit.JobQueueSysin"
        />
    </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.