diff options
author | James Moger <james.moger@gmail.com> | 2011-12-05 17:01:37 -0500 |
---|---|---|
committer | James Moger <james.moger@gmail.com> | 2011-12-05 17:01:37 -0500 |
commit | 53bdab2caad16bec8425dc173780b39bbccfc375 (patch) | |
tree | 4ad7f9eceefce08d95afcabeabfd3d7b322467b2 /src | |
parent | 4ebfeaac5790760c01fa1af11525b4964445bf93 (diff) | |
download | iciql-53bdab2caad16bec8425dc173780b39bbccfc375.tar.gz iciql-53bdab2caad16bec8425dc173780b39bbccfc375.zip |
Fixed joins on primitives
Diffstat (limited to 'src')
-rw-r--r-- | src/com/iciql/Constants.java | 4 | ||||
-rw-r--r-- | src/com/iciql/QueryJoin.java | 37 | ||||
-rw-r--r-- | src/com/iciql/QueryJoinCondition.java | 40 |
3 files changed, 79 insertions, 2 deletions
diff --git a/src/com/iciql/Constants.java b/src/com/iciql/Constants.java index dfc18af..0bd7663 100644 --- a/src/com/iciql/Constants.java +++ b/src/com/iciql/Constants.java @@ -25,11 +25,11 @@ public class Constants { // The build script extracts this exact line so be careful editing it
// and only use A-Z a-z 0-9 .-_ in the string.
- public static final String VERSION = "0.7.2";
+ public static final String VERSION = "0.7.3-SNAPSHOT";
// The build script extracts this exact line so be careful editing it
// and only use A-Z a-z 0-9 .-_ in the string.
- public static final String VERSION_DATE = "2011-11-30";
+ public static final String VERSION_DATE = "PENDING";
// The build script extracts this exact line so be careful editing it
// and only use A-Z a-z 0-9 .-_ in the string.
diff --git a/src/com/iciql/QueryJoin.java b/src/com/iciql/QueryJoin.java index bb614eb..dbb3d15 100644 --- a/src/com/iciql/QueryJoin.java +++ b/src/com/iciql/QueryJoin.java @@ -31,6 +31,43 @@ public class QueryJoin { this.join = join;
}
+ public QueryJoinCondition<Boolean> on(boolean x) {
+ return addPrimitive(x);
+ }
+
+ public QueryJoinCondition<Byte> on(byte x) {
+ return addPrimitive(x);
+ }
+
+ public QueryJoinCondition<Short> on(short x) {
+ return addPrimitive(x);
+ }
+
+ public QueryJoinCondition<Integer> on(int x) {
+ return addPrimitive(x);
+ }
+
+ public QueryJoinCondition<Long> on(long x) {
+ return addPrimitive(x);
+ }
+
+ public QueryJoinCondition<Float> on(float x) {
+ return addPrimitive(x);
+ }
+
+ public QueryJoinCondition<Double> on(double x) {
+ return addPrimitive(x);
+ }
+
+ private <A> QueryJoinCondition<A> addPrimitive(A x) {
+ A alias = query.getPrimitiveAliasByValue(x);
+ if (alias == null) {
+ // this will result in an unmapped field exception
+ return new QueryJoinCondition<A>(query, join, x);
+ }
+ return new QueryJoinCondition<A>(query, join, alias);
+ }
+
public <A> QueryJoinCondition<A> on(A x) {
return new QueryJoinCondition<A>(query, join, x);
}
diff --git a/src/com/iciql/QueryJoinCondition.java b/src/com/iciql/QueryJoinCondition.java index e5620d5..b49e35b 100644 --- a/src/com/iciql/QueryJoinCondition.java +++ b/src/com/iciql/QueryJoinCondition.java @@ -17,6 +17,7 @@ package com.iciql;
+
/**
* This class represents a query with join and an incomplete condition.
*
@@ -36,6 +37,45 @@ public class QueryJoinCondition<A> { this.x = x;
}
+ public Query<?> is(boolean y) {
+ return addPrimitive(y);
+ }
+
+ public Query<?> is(byte y) {
+ return addPrimitive(y);
+ }
+
+ public Query<?> is(short y) {
+ return addPrimitive(y);
+ }
+
+ public Query<?> is(int y) {
+ return addPrimitive(y);
+ }
+
+ public Query<?> is(long y) {
+ return addPrimitive(y);
+ }
+
+ public Query<?> is(float y) {
+ return addPrimitive(y);
+ }
+
+ public Query<?> is(double y) {
+ return addPrimitive(y);
+ }
+
+ @SuppressWarnings("unchecked")
+ private Query<?> addPrimitive(Object o) {
+ A alias = query.getPrimitiveAliasByValue((A) o);
+ if (alias == null) {
+ join.addConditionToken(new Condition<A>(x, (A) o, CompareType.EQUAL));
+ } else {
+ join.addConditionToken(new Condition<A>(x, alias, CompareType.EQUAL));
+ }
+ return query;
+ }
+
public Query<?> is(A y) {
join.addConditionToken(new Condition<A>(x, y, CompareType.EQUAL));
return query;
|