Skip to content

Commit 07707ea

Browse files
authored
Merge pull request #9 from CollinAlpert/master
Upgraded JaQue library
2 parents 6a8eb14 + ea31b90 commit 07707ea

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

Diff for: README.MD

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Lambda2sql (lambda) -> "sql"
66
Convert Java 8 lambdas to SQL statements.
77

88
For example, the following Predicate<Person>:
9-
```
9+
```jshelllanguage
1010
person -> person.getAge() < 100 && person.getHeight() > 200
1111
```
1212

@@ -22,12 +22,12 @@ See [Lambda2SqlTest](https://github.com/ajermakovics/lambda2sql/blob/master/src/
2222
Usage
2323
---------
2424

25-
```
26-
Lambda2Sql.init(); // initialize on program start, before predicates are created
27-
28-
Predicate<Person> predicate = person -> person.getAge() < 100 && person.getHeight() > 200;
25+
```jshelllanguage
26+
int age = 100;
27+
int height = 200;
28+
SqlPredicate<Person> predicate = person -> person.getAge() < age && person.getHeight() > height;
2929
30-
String sql = Lambda2Sql.toSql( predicate ); // age < 100 AND height > 200
30+
String sql = Lambda2Sql.toSql(predicate); // age < 100 AND height > 200
3131
```
3232

3333

@@ -36,12 +36,12 @@ How it works
3636

3737
It uses [JaQue](https://github.com/TrigerSoft/jaque) to build an expression tree for a lambda. The expression tree is then traversed and converted to a SQL statement.
3838

39-
Under the hood JaQue depends on the following system property:
40-
`jdk.internal.lambda.dumpProxyClasses`
39+
Under the hood, JaQue depends on the system property `jdk.internal.lambda.dumpProxyClasses`, if the lambda expression is not serialized:
4140
See [https://bugs.openjdk.java.net/browse/JDK-8023524](https://bugs.openjdk.java.net/browse/JDK-8023524).
4241

4342
When the property is enabled, JVM generated classes for lambdas are saved to disk. JaQue then uses [ASM](http://asm.ow2.org/) to read the .class files and creates expression trees.
4443

44+
Since the interface [`SqlPredicate<T>`](https://github.com/ajermakovics/lambda2sql/blob/master/src/main/java/lambda2sql/SqlPredicate.java) is automatically serialized, there is no need to set this property.
4545

4646
Limitations
4747
---------

Diff for: build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ repositories {
1515
}
1616

1717
dependencies {
18-
compile 'com.trigersoft:jaque:2.1.3'
18+
compile 'com.trigersoft:jaque:2.1.4'
1919
testCompile group: 'junit', name: 'junit', version: '4.+'
2020
}
2121

Diff for: src/test/java/lambda2sql/Lambda2SqlTest.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ public void testMultipleLogicalOps() {
3131
@Test
3232
public void testWithVariables() {
3333
String name = "Donald";
34-
//Datatype must be "Integer" for now. This is due to a bug in the JaQue library and author has been notified.
35-
//As soon as the bug is fixed, the test will be updated.
36-
Integer age = 80;
34+
int age = 80;
3735
assertEqual("name = 'Donald' AND age > 80", person -> person.getName() == name && person.getAge() > age);
3836
}
3937

Diff for: src/test/java/lambda2sql/Person.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package lambda2sql;
22

33
public interface Person {
4+
String getName();
45

5-
public String getName();
6-
public int getAge();
7-
public int getHeight();
8-
public boolean isActive();
6+
int getAge();
97

8+
int getHeight();
9+
10+
boolean isActive();
1011
}

0 commit comments

Comments
 (0)