JRC stands for Java Relational Combinator.
It is a pure Java solution for cross-dbms SQL. It allows easy code reuse of SQL code and dbms neutrality.
Features of JRC include:
- Capability of combining simple relation objects to create more sophisticated relation object, for example:
Code Block language java
Relation relation = Relations.parse("select a, b from table1").where("c>1").orderBy("c"); Relation joined= relation.alias("t1").join(Relations.table("table2").alias("t2"), "t1.id=t2.id");
- Provide enhanced dbms neutral SQL support. For example, one can use functions and enhanced features and the SQL will be translated to the SQL extension on the target dbms. For example:
This SQL will be translated to Microsoft Transact-SQL as:
select a, substr(b, 1, 2), case c when 1: "yes" else "no" end from table1 t1 inner join table2 t2 on t1.name = t2.name and t1.(a,b,c) > t2.(a,b,c)
As you shown in the example, jrc functions will be translated into the corresponding function in the target dbms. Enhanced sql features such as group comparison is also translated. Therefore one can write dbms neutral SQL code and still be able to use features not defined in the ANSI SQL standard.
select a, substring(b, 1, 2), case c when 1 then "yes" else "no" end from table1 t1 inner join table2 t2 on t1.name=t2.name and (t1.a>t2.a or t1.a=t2.a and (t1.b>t2.b or t1.b=t2.b and t1.c>t2.c))