@Override public boolean equals(Object obj) { if (obj == this) { return true; } else if (obj instanceof ConstructorExpression<?>) { ConstructorExpression<?> c = (ConstructorExpression<?>) obj; return Arrays.equals(parameterTypes, c.parameterTypes) && args.equals(c.args) && getType().equals(c.getType()); } else { return false; } }
@Test public void ConstructorProjection() { List<Projection> projections = query().from(cat).list(ConstructorExpression.create(Projection.class, cat.name, cat)); assertFalse(projections.isEmpty()); for (Projection projection : projections) { assertNotNull(projection); } }
@Test public void EntityProjections() { List<Product> products = sql() .from(product) .list( ConstructorExpression.create( Product.class, product.name, product.description, product.price, product.amount)); assertEquals(30, products.size()); for (Product p : products) { assertNotNull(p.getName()); assertNotNull(p.getDescription()); assertNotNull(p.getPrice()); assertNotNull(p.getAmount()); } }