Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
7f279062
提交
7f279062
authored
10月 05, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improved Glassfish / Toplink support in H2Platform.
上级
a2e4f74c
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
55 行增加
和
4 行删除
+55
-4
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
tutorial.html
h2/src/docsrc/html/tutorial.html
+29
-0
H2Platform.java.txt
.../toplink/essentials/platform/database/H2Platform.java.txt
+24
-3
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
7f279062
...
...
@@ -18,7 +18,8 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
-
<ul><li>
Improved Glassfish / Toplink support in H2Platform
thanks to Marcio Borges from Brazil. Thanks a lot!
</li></ul>
<h2>
Version 1.1.100 (2008-10-04)
</h2>
...
...
h2/src/docsrc/html/tutorial.html
浏览文件 @
7f279062
...
...
@@ -26,6 +26,8 @@ Tutorial
Using the Server
</a><br
/>
<a
href=
"#using_hibernate"
>
Using Hibernate
</a><br
/>
<a
href=
"#using_toplink"
>
Using TopLink and Glassfish
</a><br
/>
<a
href=
"#web_applications"
>
Using Databases in Web Applications
</a><br
/>
<a
href=
"#csv"
>
...
...
@@ -347,6 +349,33 @@ is also available at src/tools/org/hibernate/dialect/H2Dialect.java.txt.
You can rename it to H2Dialect.java and include this as a patch in your application.
</p>
<br
/><a
name=
"using_toplink"
></a>
<h2>
Using TopLink and Glassfish
</h2>
<p>
To use H2 with Glassfish (or Sun AS), set the Datasource Classname to
<code>
org.h2.jdbcx.JdbcDataSource
</code>
. You can set this in the GUI
at Application Server - Resources - JDBC - Connection Pools,
or by editing the file
<code>
sun-resources.xml
</code>
: at element
<code>
jdbc-connection-pool
</code>
, set the attribute
<code>
datasource-classname
</code>
to
<code>
org.h2.jdbcx.JdbcDataSource
</code>
.
</p>
<p>
The H2 database is compatible with HSQLDB and PostgreSQL.
To take advantage of H2 specific features, use the
<code>
H2Platform
</code>
.
The source code of this platform is included in H2 at
<code>
src/tools/oracle/toplink/essentials/platform/database/DatabasePlatform.java.txt
</code>
.
You will need to copy this file to your application, and rename it to .java.
To enable it, change the following setting in persistence.xml:
</p>
<pre>
<
property
name="toplink.target-database"
value="oracle.toplink.essentials.platform.database.H2Platform"/>
</pre>
<p>
In old versions of Glassfish, the property name is
<code>
toplink.platform.class.name
</code>
.
</p>
<br
/><a
name=
"web_applications"
></a>
<h2>
Using Databases in Web Applications
</h2>
<p>
...
...
h2/src/tools/oracle/toplink/essentials/platform/database/H2Platform.java.txt
浏览文件 @
7f279062
...
...
@@ -34,13 +34,18 @@ import oracle.toplink.essentials.internal.sessions.AbstractSession;
/**
* This platform provides H2 specific behaviour.
*
Use the following setting to enable this platform
:
*
To enable this platform change the following setting in persistence.xml
:
* <pre>
* <property
* name="toplink.
platform.class.nam
e"
* name="toplink.
target-databas
e"
* value="oracle.toplink.essentials.platform.database.H2Platform"/>
* </pre>
* In old versions of Glassfish, the property name is
* <code>toplink.platform.class.name</code>.
* See also: https://glassfish.dev.java.net/issues/show_bug.cgi?id=4042
*
* @author Thomas Mueller
* @author Marcio Borges (http://www.marciowb.net/blog/2008_08_01_)
*/
public class H2Platform extends DatabasePlatform {
public H2Platform() {
...
...
@@ -87,7 +92,15 @@ public class H2Platform extends DatabasePlatform {
}
public ValueReadQuery buildSelectQueryForNativeSequence(String seqName, Integer size) {
return new ValueReadQuery("CALL NEXT VALUE FOR " + getQualifiedSequenceName(seqName));
StringBuffer buff = new StringBuffer();
buff.append("SELECT MAX(NEXT VALUE FOR ");
buff.append(getQualifiedSequenceName(seqName));
buff.append(") FROM SYSTEM_RANGE(1, ");
buff.append(size);
buff.append(")");
String sql = buff.toString();
return new ValueReadQuery(sql);
// return new ValueReadQuery("CALL NEXT VALUE FOR " + getQualifiedSequenceName(seqName));
// return new ValueReadQuery("SELECT " + getQualifiedSequenceName(seqName) + ".NEXTVAL FROM DUAL");
}
...
...
@@ -119,5 +132,13 @@ public class H2Platform extends DatabasePlatform {
public boolean shouldUseJDBCOuterJoinSyntax() {
return false;
}
public boolean supportsIdentity() {
return true;
}
public ValueReadQuery buildSelectQueryForIdentity() {
return new ValueReadQuery("SELECT IDENTITY()");
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论