ColdBox ORM Module
Yes, you can also create associations in Detached Criteria Builder, just like you would with Criteria Builder. Go on, make some uber-complicated queries!
Here we go!...
You can also navigate associations by nesting the criterias using the createCriteria("association_name") method and then concatenating the properties of the association to query upon. You will basically be switching the pivot point of the query.
var c = newCriteria("User");
var users ="name","lui%")
var c = newCriteria("User");
var users ="name","lui%")
You can also use a hibernate property approach which aliases the association much how HQL approaches it by using the joinTo( "associationName", "alias" ) method:
var c = newCriteria("User");
var users ="name","lui%")
The joinTo() method accepts a third argument of joinType, which can be retrieved from the criteria object:
var c = newCriteria( "User" );
var users = "name", "lui%" )
.joinTo( "admins", "a", c.RIGHT_JOIN )
.eq( "", "Vero" )
Let's see the method signatures for these guys:
createCriteria(required string associationName,numeric joinType)
joinTo(required string associationName, required string alias, numeric joinType)
with{AssociationName}( joinType )
Export as PDF
Copy link
Edit on GitHub