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