IQL Support for Like, QBE and Join
Inductor provides a rather robust set of SQL-type operators. Although implemented as a layer over different persistence packages, Inductor is able to provide a unified IQL syntax that actually implements a super-set of the functions native to the underlying persistence packages. Perhaps the most significant addition is the addition of QBE capabilities to the JDO packages and Field#in and Field#between to both Hibernate and JDO. Also, the join function of Hibernate has been significantly simplified and effectively standardized.
Below is an introduction to these features.
Like and its Variants
- Field#like: implements a single parameter pattern matching function.
- Field#startsWith: implements a single parameter pattern matching function where the parameter defines the start-point literal of any matching value. A trailing, multiple character wildcard is implied.
- Field#endsWith: implements a single parameter pattern matching function where the parameter defines the end-point literal of any matching value. A leading, multiple character wildcard is implied.
- Field#between: implements a two parameter pattern matching function where the two parameters define the end-points of a valid match range.
- Field#in: implements an array parameter pattern matching function.
Like Operator and Variants:
q.where(fname.like("M%ry");
q.where(fname.startsWith("M").endsWith("ry");
q.where(fname.between("M%", "%ry");
q.where(fname.in(new String[] { "M_ry", "M_rry", "M%th%r_y" });
By default, the IQL implementation of the like and related constraints use ANSI-SQL standard wildcards: '%' for multicharacter matching and '_' for single character matches. Inductor can be switched to using the native wildcards of the underlying persistence package by a method call applied to the driver.
QBE
A full QBE query can be performed using the view-name field defined within a field-name class.
Persistence Capable Class Instance
// create instance with desired values
Employee e = new Employee();
e.setFName("M%");
e.setLName("Richards");
e.setTitle("%Officer%");
Field-Name Class:
// persistence record reference public Class record = Employee.class; ... // view-name field public Field qbe = new Field(record);
QBE Query:
q.where(qbe.like(e));
Based on the values contained in the persistence-capable class instance, the non-blank Fields defined in the applicable Field-Name class are matched using a like operator. That is, the QBE is performed on the intersection of (1) non-zero numbers and (2) non-null, non-zero length strings in the persistent class object, and (3) for only those Fields defined within the field-name class that contains the view-name Field.
Joins
Works, just missing the write-up.