-->
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: Hibernate Criteria Queries - Dynamic Depth and Breadth Issue
PostPosted: Wed May 05, 2010 6:34 pm 
Newbie

Joined: Wed May 05, 2010 6:19 pm
Posts: 2
Ok, So I know that I can chase to any depth (meaning number of "hops" from the base object to far away objects

(Example using manufacturer, make and model of cars - the query is intended to list a count of car models made by Volkswagen)
Code:
session.createCriteria( model.class )
  .setProjection( Projections.rowCount() )
  .createCriteria( "make" )
  .createCriteria( "manufacturer" )
  .add( Restrictions.eq( "name", "Volkswagen" );



And I know I can chase to any breadth - meaning several different joins to objects all 1 hop away.
(Example using characteristics of a specific car model)
Code:
session.createCriteria( model.class )
  .setProjection( Projections.rowCount() )
  .createAlias( "color", "clr" )
    .add( Restrictions.eq( "clr.name", "Tornado Red" )
  .createAlias( "doors", "dr" )
    .add( Restrictions.eq( "dr.type", 4)
  .createAlias( "rims", "rms" )
    .add( Restrictions.eq( "rms.size", 16)


But how do I do both at the same time? What would the criteria query be, for example if I wanted a count of Models that were red 4-door Volkswagens?

In essence - My needs at the moment are to be able to create count queries that can have any given depth as well as any given breadth at any depth.. am I out of luck trying to use the Criteria API for this?

I look forward to all good ideas!

-Del


Top
 Profile  
 
 Post subject: Re: Hibernate Criteria Queries - Dynamic Depth and Breadth Issue
PostPosted: Mon May 24, 2010 2:37 pm 
Newbie

Joined: Wed May 05, 2010 6:19 pm
Posts: 2
No ideas?

-Del


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.