Detached Criteria Builder
Using Detached Criteria Builder in CBORM for complex queries
Last updated
Was this helpful?
Was this helpful?
var c = newCriteria();
c.add(
c.createSubCriteria()
);prc.pageTitle = "Criteria Builder - Subquery";
var c = carService.newCriteria();
// add subquery
prc.results = c.add(
c.createSubcriteria( "Car", "carstaff" )
// the property in the subquery to use or retrieve
.withProjections( property : "CarID" )
.joinTo( "carstaff.SalesPeople", "staff" )
.joinTo( "staff.Position", "position" )
.isEq( "position.LongName", "Finance Officer" )
// then we use propertyIn() to get all the Cars from the sub query
.propertyIn( "CarID" )
)
.list()
// Map it to the memento, so we can see it nicely.
.map( function( item ){
return item.getMemento();
} );