JRel 是一个使用Java方法来构建数据库查询的类库。使用方法如下:
Query query = new Query() .from(customer, product, order) .restrict(customer.ID).eq(5)) .project(customer.FIRST_NAME, customer.ID, product.ID) .join(product.ID.eq(order.PRODUCT_ID)) .join(customer.ID.eq(order.CUSTOMER_ID));
将会转换为
SELECT c.first_name, c.id, p.id FROM order AS o JOIN product AS p ON p.id = o.product_id JOIN customer AS c ON c.id = o.customer_id WHERE c.id = 5
更多的例子:http://www.thimbleware.com/projects/jrel/wiki/Examples