@Test public void script42_DateTime() { QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); Query<Person> query = unitOfWork.newQuery( qb.where( ne( person.dateTimeValue(), new DateTime( "2010-03-04T14:24:35", forID( "CET" ) ) ) ) ); System.out.println( "*** script42_DateTime: " + query ); verifyUnorderedResults( query, "Jack Doe", "Joe Doe" ); }
@Test public void script42_LocalDate() { QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); Query<Person> query = unitOfWork.newQuery( qb.where( ne( person.localDateValue(), new LocalDate( "2010-03-04", forID( "CET" ) ) ) ) ); System.out.println( "*** script42_LocalDate: " + query ); verifyUnorderedResults( query, "Joe Doe" ); }
@Test public void script51_BigInteger() { QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); Query<Person> query = unitOfWork.newQuery( qb.where( ne( person.bigInteger(), new BigInteger( "23232323232323232323232323" ) ) ) ); System.out.println( "*** script51_BigInteger: " + query ); verifyUnorderedResults( query, "Jack Doe" ); }
@Test public void script40_DateTime() { QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.dateTimeValue(), new DateTime( "2010-03-04T13:24:35", UTC ) ) ) ); System.out.println( "*** script40_DateTime: " + query ); verifyUnorderedResults( query, "Jack Doe" ); }
@Test public void script52_BigInteger() { QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); Query<Person> query = unitOfWork.newQuery( qb.where( ge( person.bigInteger(), new BigInteger( "23232323232323232323232323" ) ) ) ); System.out.println( "*** script52_BigInteger: " + query ); verifyUnorderedResults( query, "Jack Doe", "Joe Doe" ); }
@Test public void script42_LocalDateTime() { QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); Query<Person> query = unitOfWork.newQuery( qb.where( ne( person.localDateTimeValue(), new LocalDateTime( "2010-03-04T13:23:00", forID( "CET" ) ) ) ) ); System.out.println( "*** script42_LocalDateTime: " + query ); verifyUnorderedResults( query, "Joe 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 script43_DateTime() { QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); Query<Person> query = unitOfWork.newQuery( qb.where( and( gt( person.dateTimeValue(), new DateTime( "2005-03-04T13:24:35", UTC ) ), lt( person.dateTimeValue(), new DateTime( "2015-03-04T13:24:35", UTC ) ) ) ) ); System.out.println( "*** script43_DateTime: " + query ); verifyUnorderedResults( query, "Jack Doe" ); }
@Test public void script11() throws EntityFinderException { QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); Query<Person> query = unitOfWork.newQuery( qb.where( isNotNull( person.email() ) ) ); System.out.println( "*** script11: " + query ); verifyUnorderedResults( query, "Joe Doe" ); }
@Test public void script39() { QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); Query<Person> query = unitOfWork.newQuery( qb.where( ne( person.title(), Person.Title.DR ) ) ); System.out.println( "*** script39: " + query ); verifyUnorderedResults( query, "Ann Doe", "Joe Doe" ); }
@Test public void script02() throws EntityFinderException { final QueryBuilder<Domain> qb = this.module.newQueryBuilder( Domain.class ); final Nameable nameable = templateFor( Nameable.class ); final Query<Domain> query = unitOfWork.newQuery( qb.where( eq( nameable.name(), "Gaming" ) ) ); System.out.println( "*** script02: " + query ); verifyUnorderedResults( query, "Gaming" ); }
@Test public void script15() throws EntityFinderException { QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); Male person = templateFor( Male.class ); Query<Person> query = unitOfWork.newQuery( qb.where( isNull( person.wife() ) ) ); System.out.println( "*** script15: " + query ); verifyUnorderedResults( query, "Joe Doe", "Ann Doe" ); }
@Test public void script22() throws EntityFinderException { QueryBuilder<Nameable> qb = this.module.newQueryBuilder( Nameable.class ); Nameable nameable = templateFor( Nameable.class ); // should return Jack and Joe Doe Query<Nameable> query = unitOfWork.newQuery( qb.where( matches( nameable.name(), "J.*Doe" ) ) ); System.out.println( "*** script22: " + query ); verifyUnorderedResults( query, "Jack Doe", "Joe Doe" ); }
@Test public void script38() { QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.title(), Person.Title.DR ) ) ); System.out.println( "*** script38: " + query ); verifyUnorderedResults( query, "Jack Doe" ); }
@Test public void script12_ne() throws EntityFinderException { QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); Query<Person> query = unitOfWork.newQuery( qb.where( ne( person.email(), "joe@thedoes.net" ) ) ); System.out.println( "*** script12_ne: " + query ); verifyUnorderedResults( query ); }
@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 @SuppressWarnings( "unchecked" ) public void script08() throws EntityFinderException { QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); Query<Person> query = unitOfWork.newQuery( qb.where( or( eq( person.yearOfBirth(), 1970 ), eq( person.yearOfBirth(), 1975 ) ) ) ); System.out.println( "*** script08: " + query ); verifyUnorderedResults( query, "Jack Doe", "Ann Doe" ); }
@Test @SuppressWarnings( "unchecked" ) public void script09() throws EntityFinderException { QueryBuilder<Female> qb = this.module.newQueryBuilder( Female.class ); Person person = templateFor( Person.class ); Query<Female> query = unitOfWork.newQuery( qb.where( or( eq( person.yearOfBirth(), 1970 ), eq( person.yearOfBirth(), 1975 ) ) ) ); System.out.println( "*** script09: " + query ); verifyUnorderedResults( query, "Ann Doe" ); }
@Test @Ignore( "Traversing of NamedAssociations is not implemented" ) public void script37() { QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class ); Person person = templateFor( Person.class ); Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.accounts().get( "anns" ).number(), "accountOfAnnDoe" ) ) ); System.out.println( "*** script37: " + query ); verifyUnorderedResults( query, "Jack Doe", "Ann Doe" ); }
@Test @SuppressWarnings( "unchecked" ) public void script07() throws EntityFinderException { QueryBuilder<Nameable> qb = this.module.newQueryBuilder( Nameable.class ); Person person = templateFor( Person.class ); Query<Nameable> query = unitOfWork.newQuery( qb.where( and( ge( person.yearOfBirth(), 1900 ), eq( person.placeOfBirth().get().name(), "Penang" ) ) ) ); System.out.println( "*** script07: " + query ); verifyUnorderedResults( query, "Jack Doe" ); }