@Test public void script20() throws EntityFinderException { Person person = templateFor( Person.class ); final Query<Person> query = unitOfWork.newQuery( this.module .newQueryBuilder( Person.class ) .where( queries.get( "script20" ) ) ); query.orderBy( orderBy( person.name(), OrderBy.Order.DESCENDING ) ); System.out.println( "*** script20: " + query ); verifyOrderedResults( query, "Joe Doe", "Ann Doe" ); }
@Test public void script19() throws EntityFinderException { Nameable nameable = templateFor( Nameable.class ); final Query<Nameable> query = unitOfWork.newQuery( this.module .newQueryBuilder( Nameable.class ) .where( queries.get( "script19" ) ) ); query.orderBy( orderBy( nameable.name() ) ); System.out.println( "*** script19: " + query ); verifyOrderedResults( query, "Gaming", "Jack Doe", "Joe Doe", "Kuala Lumpur", "Penang", "Programming" ); }
@Test public void script18() throws EntityFinderException { Nameable nameable = templateFor( Nameable.class ); final Query<Nameable> query = unitOfWork.newQuery( this.module .newQueryBuilder( Nameable.class ) .where( queries.get( "script18" ) ) ); query.orderBy( orderBy( nameable.name() ) ); System.out.println( "*** script18: " + query ); verifyOrderedResults( query, "Ann Doe", "Cars", "Cooking", "Gaming", "Jack Doe", "Joe Doe", "Kuala Lumpur", "Penang", "Programming" ); }
@Test public void script16() throws EntityFinderException { Nameable nameable = templateFor( Nameable.class ); final Query<Nameable> query = unitOfWork.newQuery( this.module .newQueryBuilder( Nameable.class ) .where( queries.get( "script16" ) ) ); query.orderBy( orderBy( nameable.name() ) ); query.maxResults( 2 ); System.out.println( "*** script16: " + query ); verifyOrderedResults( query, "Ann Doe", "Cars" ); }
@Test public void script18() throws EntityFinderException { QueryBuilder<Nameable> qb = this.module.newQueryBuilder( Nameable.class ); // should return all Nameable entities sorted by name Nameable nameable = templateFor( Nameable.class ); Query<Nameable> query = unitOfWork.newQuery( qb ); query.orderBy( orderBy( nameable.name() ) ); System.out.println( "*** script18: " + query ); verifyOrderedResults( query, "Ann Doe", "Cars", "Cooking", "Gaming", "Jack Doe", "Joe Doe", "Kuala Lumpur", "Penang", "Programming" ); }
@Test public void script17() throws EntityFinderException { Nameable nameable = templateFor( Nameable.class ); final Query<Nameable> query = unitOfWork.newQuery( this.module .newQueryBuilder( Nameable.class ) .where( queries.get( "script17" ) ) ); query.orderBy( orderBy( nameable.name() ) ); query.firstResult( 3 ); query.maxResults( 3 ); System.out.println( "*** script17: " + query ); verifyOrderedResults( query, "Gaming", "Jack Doe", "Joe Doe" ); }
@Test public void script16() throws EntityFinderException { QueryBuilder<Nameable> qb = this.module.newQueryBuilder( Nameable.class ); // should return only 2 entities Nameable nameable = templateFor( Nameable.class ); Query<Nameable> query = unitOfWork.newQuery( qb ); query.orderBy( orderBy( nameable.name() ) ); query.maxResults( 2 ); System.out.println( "*** script16: " + query ); verifyOrderedResults( query, "Ann Doe", "Cars" ); }
@Test public void script17() throws EntityFinderException { QueryBuilder<Nameable> qb = this.module.newQueryBuilder( Nameable.class ); // should return only 3 entities starting with forth one Nameable nameable = templateFor( Nameable.class ); Query<Nameable> query = unitOfWork.newQuery( qb ); query.orderBy( orderBy( nameable.name() ) ); query.firstResult( 3 ); query.maxResults( 2 ); System.out.println( "*** script17: " + query ); verifyOrderedResults( query, "Gaming", "Jack Doe" ); }
@Test public void script20() throws EntityFinderException { QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); // should return all Persons born after 1973 (Ann and Joe Doe) sorted descending by name Person person = templateFor( Person.class ); Query<Person> query = unitOfWork.newQuery( qb.where( gt( person.yearOfBirth(), 1973 ) ) ); query.orderBy( orderBy( person.name(), OrderBy.Order.DESCENDING ) ); System.out.println( "*** script20: " + query ); verifyOrderedResults( query, "Joe Doe", "Ann Doe" ); }
@Test public void script19() throws EntityFinderException { QueryBuilder<Nameable> qb = this.module.newQueryBuilder( Nameable.class ); // should return all Nameable entities with a name > "D" sorted by name Nameable nameable = templateFor( Nameable.class ); Query<Nameable> query = unitOfWork.newQuery( qb.where( gt( nameable.name(), "D" ) ) ); query.orderBy( orderBy( nameable.name() ) ); System.out.println( "*** script19: " + query ); verifyOrderedResults( query, "Gaming", "Jack Doe", "Joe Doe", "Kuala Lumpur", "Penang", "Programming" ); }
@Test public void script21() throws EntityFinderException { QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); // should return all Persons sorted by name of the city they were born, and then by year they were born Person person = templateFor( Person.class ); Query<Person> query = unitOfWork.newQuery( qb ); query.orderBy( orderBy( person.placeOfBirth().get().name() ), orderBy( person.yearOfBirth() ) ); System.out.println( "*** script21: " + query ); verifyOrderedResults( query, "Ann Doe", "Joe Doe", "Jack Doe" ); }
@Test public void script21() throws EntityFinderException { Person person = templateFor( Person.class ); final Query<Person> query = unitOfWork.newQuery( this.module .newQueryBuilder( Person.class ) .where( queries.get( "script21" ) ) ); query.orderBy( orderBy( person.placeOfBirth().get().name() ), orderBy( person.yearOfBirth() ) ); System.out.println( "*** script21: " + query ); verifyOrderedResults( query, "Ann Doe", "Joe Doe", "Jack Doe" ); }