@Test public void testAssociated() throws Exception { /* Following request mean is : * Looking for any product which price is between 15 and 25, * and name starts with 'Paint', * and with an associated category which name is 'Hardware' */ Restriction dto = q() .bw( "Product.price", "15", "25") .sw( "Product.name", "Paint") .associated( "Product.category" ) .eq( "Category.name", "Hardware" ) .criteria().getRestriction(); Assert.assertTrue( "Restriction is " + dto.getClass().getName(), dto instanceof AssociatedRestriction ); AssociatedRestriction ass = (AssociatedRestriction) dto; Restriction embedded = ass.getRestriction(); Assert.assertTrue( "Restriction is " + dto.getClass().getName(), embedded instanceof Equals ); checkRestriction(embedded, RestrictionName.EQUALS, "Category.name", "Hardware"); Assert.assertEquals( "Product.category", ass.getElement().getName() ); }