Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c93bf7a6
提交
c93bf7a6
authored
15 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
JaQu: the plan is to support natural (pure Java) conditions.
上级
2afa260c
全部展开
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
1472 行增加
和
5 行删除
+1472
-5
jaqu.html
h2/src/docsrc/html/jaqu.html
+20
-1
SamplesTest.java
h2/src/test/org/h2/test/jaqu/SamplesTest.java
+4
-4
Query.java
h2/src/tools/org/h2/jaqu/Query.java
+4
-0
ClassReader.java
h2/src/tools/org/h2/jaqu/util/ClassReader.java
+1444
-0
没有找到文件。
h2/src/docsrc/html/jaqu.html
浏览文件 @
c93bf7a6
...
@@ -256,7 +256,26 @@ This is not possible using annotations.
...
@@ -256,7 +256,26 @@ This is not possible using annotations.
Unlike XML mapping configuration, the configuration is integrated in the class itself.
Unlike XML mapping configuration, the configuration is integrated in the class itself.
</p>
</p>
<h2>
Ideas
</h2>
<h2>
Natural Syntax
</h2>
<p>
The plan is to support more natural (pure Java) syntax in conditions.
To do that, the condition class is de-compiled to a SQL condition.
A proof of concept decompiler is included (but it doesn't work yet).
The planned syntax is:
</p>
<pre>
long count = db.from(co).
where(new Filter() { public boolean where() {
return co.id == x
&&
co.name.equals(name)
&&
co.value == new BigDecimal("1")
&&
co.amount == 1L
&&
co.birthday.before(new java.util.Date())
&&
co.created.before(java.sql.Timestamp.valueOf("2005-05-05 05:05:05"))
&&
co.time.before(java.sql.Time.valueOf("23:23:23"));
} }).selectCount();
</pre>
<h2>
Other Ideas
</h2>
<p>
<p>
This project has just been started, and nothing is fixed yet.
This project has just been started, and nothing is fixed yet.
Some ideas for what to implement are:
Some ideas for what to implement are:
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/jaqu/SamplesTest.java
浏览文件 @
c93bf7a6
...
@@ -347,12 +347,12 @@ private void testComplexObject2(final int x, final String name) {
...
@@ -347,12 +347,12 @@ private void testComplexObject2(final int x, final String name) {
long
count
=
db
.
from
(
co
).
long
count
=
db
.
from
(
co
).
where
(
new
Filter
()
{
public
boolean
where
()
{
where
(
new
Filter
()
{
public
boolean
where
()
{
return
co
.
id
==
x
return
co
.
id
==
x
&&
co
.
name
.
equals
(
name
)
&&
co
.
value
==
new
BigDecimal
(
"1"
)
&&
co
.
amount
==
1L
&&
co
.
amount
==
1L
&&
co
.
birthday
.
before
(
new
java
.
util
.
Date
())
&&
co
.
birthday
.
before
(
new
java
.
util
.
Date
())
&&
co
.
created
.
before
(
java
.
sql
.
Timestamp
.
valueOf
(
"2005-05-05 05:05:05"
))
&&
co
.
created
.
before
(
java
.
sql
.
Timestamp
.
valueOf
(
"2005-05-05 05:05:05"
))
&&
co
.
name
.
equals
(
name
)
&&
co
.
time
.
before
(
java
.
sql
.
Time
.
valueOf
(
"23:23:23"
));
&&
co
.
time
.
before
(
java
.
sql
.
Time
.
valueOf
(
"23:23:23"
))
&&
co
.
value
==
new
BigDecimal
(
"1"
);
}
}).
selectCount
();
}
}).
selectCount
();
// TODO should return only one object
// TODO should return only one object
assertEquals
(
2
,
count
);
assertEquals
(
2
,
count
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/jaqu/Query.java
浏览文件 @
c93bf7a6
...
@@ -14,6 +14,7 @@ import java.util.ArrayList;
...
@@ -14,6 +14,7 @@ import java.util.ArrayList;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
org.h2.jaqu.util.ClassReader
;
import
org.h2.jaqu.util.Utils
;
import
org.h2.jaqu.util.Utils
;
//## Java 1.5 end ##
//## Java 1.5 end ##
...
@@ -178,6 +179,9 @@ public class Query<T> {
...
@@ -178,6 +179,9 @@ public class Query<T> {
// // convert
// // convert
// }
// }
}
}
// String filterQuery =
new
ClassReader
().
decompile
(
filter
,
"where"
);
// System.out.println(filterQuery);
return
new
QueryWhere
<
T
>(
this
);
return
new
QueryWhere
<
T
>(
this
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/jaqu/util/ClassReader.java
0 → 100644
浏览文件 @
c93bf7a6
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论