提交 d22a1a41 authored 作者: Thomas Mueller's avatar Thomas Mueller

Improve docs

上级 8ec01485
...@@ -50,7 +50,7 @@ http://www.h2database.com/html/roadmap.html ...@@ -50,7 +50,7 @@ http://www.h2database.com/html/roadmap.html
<p> <p>
The development of H2 was started in May 2004, The development of H2 was started in May 2004,
but it was first published on December 14th 2005. but it was first published on December 14th 2005.
The author of H2, Thomas Mueller, is also the original developer of Hypersonic SQL. The main author of H2, Thomas Mueller, is also the original developer of Hypersonic SQL.
In 2001, he joined PointBase Inc. where he created PointBase Micro. In 2001, he joined PointBase Inc. where he created PointBase Micro.
At that point, he had to discontinue Hypersonic SQL, but then the HSQLDB Group was formed At that point, he had to discontinue Hypersonic SQL, but then the HSQLDB Group was formed
to continued to work on the Hypersonic SQL codebase. to continued to work on the Hypersonic SQL codebase.
......
...@@ -21,7 +21,7 @@ JaQu ...@@ -21,7 +21,7 @@ JaQu
<p> <p>
JaQu stands for Java Query and allows to access databases using pure Java. JaQu stands for Java Query and allows to access databases using pure Java.
JaQu provides a fluent interface (or internal DSL) for building SQL statements. JaQu provides a fluent interface (or internal DSL) for building SQL statements.
JaQu replaces SQL, JDBC, and object/relation frameworks such as Hibernate. JaQu replaces SQL, JDBC, and persistence frameworks such as Hibernate.
JaQu is something like LINQ for Java (LINQ stands for "language integrated query" and is a JaQu is something like LINQ for Java (LINQ stands for "language integrated query" and is a
Microsoft .NET technology). The following JaQu code: Microsoft .NET technology). The following JaQu code:
</p> </p>
...@@ -38,14 +38,14 @@ SELECT * FROM PRODUCTS P ...@@ -38,14 +38,14 @@ SELECT * FROM PRODUCTS P
WHERE P.UNITS_IN_STOCK = 0 WHERE P.UNITS_IN_STOCK = 0
</pre> </pre>
<h2>Advantages and Differences to other Data Access Tools</h2> <h2>Advantages and Differences to Other Data Access Tools</h2>
<p> <p>
Unlike SQL, JaQu can be easily integrated in Java applications. Because JaQu is pure Java, Unlike SQL, JaQu can be easily integrated in Java applications. Because JaQu is pure Java,
Javadoc and auto-complete are supported. Type checking is performed by the compiler. auto-complete in the IDE and Javadoc and are supported. Type checking is performed by the compiler.
JaQu fully protects against SQL injection. JaQu fully protects against SQL injection.
</p> </p>
<p> <p>
JaQu is much smaller than object/relation mapping tools such as Hibernate. JaQu is much smaller than persistence frameworks such as Hibernate.
Unlike iBatis and Hibernate, no XML or annotation based configuration is required; Unlike iBatis and Hibernate, no XML or annotation based configuration is required;
instead the configuration (if required at all) is done in pure Java, in the application itself. instead the configuration (if required at all) is done in pure Java, in the application itself.
</p> </p>
...@@ -56,15 +56,14 @@ JaQu provides full control over when and what SQL statements are executed. ...@@ -56,15 +56,14 @@ JaQu provides full control over when and what SQL statements are executed.
<h3>Restrictions</h3> <h3>Restrictions</h3>
<p> <p>
Primitive types (eg. boolean, int, long, double) are not supported. Instead, Primitive types (eg. boolean, int, long, double) are not supported. Use
Boolean, Integer, Long, and Double must be used. Boolean, Integer, Long, and Double instead.
</p> </p>
<h3>Why in Java?</h3> <h3>Why in Java?</h3>
<p> <p>
Most people use Java in their application. Mixing Java and another language (for example Scala or Groovy) Most people use Java in their application. Mixing Java and another language (for example Scala or Groovy)
in the same application is complicated. It would be required to split the code to access the database in the same application is complicated: You would need to split the application and database code.
and the application code.
</p> </p>
<h2>Current State</h2> <h2>Current State</h2>
...@@ -162,7 +161,7 @@ public class Test { ...@@ -162,7 +161,7 @@ public class Test {
final Product p = new Product(); final Product p = new Product();
List&lt;ProductPrice> productInfos = List&lt;ProductPrice> productInfos =
db.from(p).orderBy(p.productId). db.from(p).orderBy(p.productId).
select(new ProductPrice() { { select(new ProductPrice() {{
productName = p.productName; productName = p.productName;
category = p.category; category = p.category;
price = p.unitPrice; price = p.unitPrice;
...@@ -183,7 +182,7 @@ public class Test { ...@@ -183,7 +182,7 @@ public class Test {
innerJoin(o).on(c.customerId).is(o.customerId). innerJoin(o).on(c.customerId).is(o.customerId).
where(o.total).smaller(new BigDecimal("500.00")). where(o.total).smaller(new BigDecimal("500.00")).
orderBy(1). orderBy(1).
select(new CustOrder() { { select(new CustOrder() {{
customerId = c.customerId; customerId = c.customerId;
orderId = o.orderId; orderId = o.orderId;
total = o.total; total = o.total;
...@@ -192,7 +191,8 @@ public class Test { ...@@ -192,7 +191,8 @@ public class Test {
private void testLength() throws Exception { private void testLength() throws Exception {
Product p = new Product(); Product p = new Product();
List&lt;Integer> lengths = db.from(p). List&lt;Integer> lengths =
db.from(p).
where(length(p.productName)).smaller(10). where(length(p.productName)).smaller(10).
orderBy(1). orderBy(1).
selectDistinct(length(p.productName)); selectDistinct(length(p.productName));
...@@ -213,7 +213,7 @@ public class Test { ...@@ -213,7 +213,7 @@ public class Test {
db.from(p). db.from(p).
groupBy(p.category). groupBy(p.category).
orderBy(1). orderBy(1).
select(new ProductGroup() { { select(new ProductGroup() {{
category = p.category; category = p.category;
productCount = count(); productCount = count();
}}); }});
...@@ -224,7 +224,7 @@ public class Test { ...@@ -224,7 +224,7 @@ public class Test {
<h2>Configuration</h2> <h2>Configuration</h2>
<p> <p>
JaQu does not require any kind of configuration is you want to use the default mapping. JaQu does not require any configuration when using the default mapping.
To define table indices, or if you want to map a class to a table with a different name, To define table indices, or if you want to map a class to a table with a different name,
or a field to a column with another name, create a function called 'define' in the data class. or a field to a column with another name, create a function called 'define' in the data class.
Example: Example:
...@@ -243,22 +243,23 @@ public class Product implements Table { ...@@ -243,22 +243,23 @@ public class Product implements Table {
primaryKey(productId); primaryKey(productId);
index(productName, category); index(productName, category);
} }
}
</pre> </pre>
<p> <p>
The method 'define()' contains the mapping definition. It is called once The method 'define()' contains the mapping definition. It is called once
when the class is used for the first time. Like annotations, the mapping is defined in the class itself. when the class is used for the first time. Like annotations, the mapping is defined in the class itself.
Unlike when using annotations, the compiler can check the syntax even for multi-column Unlike when using annotations, the compiler can check the syntax even for multi-column
objects (multi-column indexes, multi-column primary keys and so on). objects (multi-column indexes, multi-column primary keys and so on).
This solution is very flexible because the definition is written in regular Java code: Because the definition is written in regular Java, the configuration can depend on the environment.
Unlike when using annotations, your code can select the right configuration depending This is not possible using annotations.
on the environment if required. Unlike XML mapping configuration, the configuration Unlike XML mapping configuration, the configuration is integrated in the class itself.
is integrated in the class itself.
</p> </p>
<h2>Ideas</h2> <h2>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 include: Some ideas for what to implement are:
</p> </p>
<ul><li>Support queries on collections (instead of using a database). <ul><li>Support queries on collections (instead of using a database).
</li><li>Provide API level compatibility with JPA (so that JaQu can be used as an extension of JPA). </li><li>Provide API level compatibility with JPA (so that JaQu can be used as an extension of JPA).
......
...@@ -35,9 +35,9 @@ There is a License FAQ for both the MPL and the EPL, most of that is applicable ...@@ -35,9 +35,9 @@ There is a License FAQ for both the MPL and the EPL, most of that is applicable
<p> <p>
However, nobody is allowed to rename H2, modify it a little, and sell it as a database engine without telling the customers it is in fact H2. However, nobody is allowed to rename H2, modify it a little, and sell it as a database engine without telling the customers it is in fact H2.
This happened to HSQLDB, when a company called 'bungisoft' copied HSQLDB, renamed it to 'RedBase', and tried to sell it, This happened to HSQLDB: A company called 'bungisoft' copied HSQLDB, renamed it to 'RedBase', and tried to sell it,
hiding the fact that it was, in fact, just HSQLDB. At this time, it seems 'bungisoft' does not exist any more, but you can use the hiding the fact that it was in fact just HSQLDB. It seems 'bungisoft' does not exist any more, but you can use the
Wayback Machine of http://www.archive.org and look for old web pages of http://www.bungisoft.com . Wayback Machine of http://www.archive.org and visit old web pages of http://www.bungisoft.com .
</p><p> </p><p>
About porting the source code to another language (for example C# or C++): Converted source code (even if done manually) stays under the same About porting the source code to another language (for example C# or C++): Converted source code (even if done manually) stays under the same
copyright and license as the original code. The copyright of the ported source code does not (automatically) go to the person who ported the code. copyright and license as the original code. The copyright of the ported source code does not (automatically) go to the person who ported the code.
...@@ -466,8 +466,8 @@ described in <a href="#exhibit-a">Exhibit A</a>. ...@@ -466,8 +466,8 @@ described in <a href="#exhibit-a">Exhibit A</a>.
<h3 id="exhibit-a">Exhibit A</h3> <h3 id="exhibit-a">Exhibit A</h3>
<pre> <pre>
Multiple-Licensed under the H2 License, Multiple-Licensed under the H2 License, Version 1.0,
Version 1.0, and under the Eclipse Public License, Version 1.0 and under the Eclipse Public License, Version 1.0
(http://h2database.com/html/license.html). (http://h2database.com/html/license.html).
Initial Developer: H2 Group Initial Developer: H2 Group
</pre> </pre>
......
...@@ -221,7 +221,7 @@ Java job scheduler, file transfer, workflow, and BPM. ...@@ -221,7 +221,7 @@ Java job scheduler, file transfer, workflow, and BPM.
<p><a href="http://ggc.sourceforge.net"> <p><a href="http://ggc.sourceforge.net">
GNU Gluco Control</a><br /> GNU Gluco Control</a><br />
Helps you to manage your diabetes.. Helps you to manage your diabetes.
</p> </p>
<p><a href="http://www.goldenstudios.or.id"> <p><a href="http://www.goldenstudios.or.id">
...@@ -409,6 +409,11 @@ OpenGroove</a><br /> ...@@ -409,6 +409,11 @@ OpenGroove</a><br />
OpenGroove is a groupware program that allows users to synchronize data. OpenGroove is a groupware program that allows users to synchronize data.
</p> </p>
<p><a href="http://code.google.com/p/opensocial-development-environment">
OpenSocial Development Environment (OSDE)</a><br />
Development tool for OpenSocial application.
</p>
<p><a href="http://www.orionserver.com"> <p><a href="http://www.orionserver.com">
Orion</a><br /> Orion</a><br />
J2EE Application Server. J2EE Application Server.
......
...@@ -17,7 +17,7 @@ H2 Database Engine ...@@ -17,7 +17,7 @@ H2 Database Engine
<h1>H2 Database Engine</h1> <h1>H2 Database Engine</h1>
<p> <p>
Welcome to H2, the free SQL database engine. Welcome to H2, the free Java SQL database engine.
</p> </p>
<br /> <br />
......
...@@ -22,8 +22,8 @@ H2 Database Engine ...@@ -22,8 +22,8 @@ H2 Database Engine
Welcome to H2, the Java SQL database. The main feature of H2 are: Welcome to H2, the Java SQL database. The main feature of H2 are:
</p> </p>
<ul> <ul>
<li>Very fast, open source, JDBC and ODBC API <li>Very fast, open source, JDBC API
</li><li>Embedded, server and cluster modes; in-memory databases </li><li>Embedded and server modes; in-memory databases
</li><li>Browser based Console application </li><li>Browser based Console application
</li><li>Small footprint: around 1 MB jar file size </li><li>Small footprint: around 1 MB jar file size
</li></ul> </li></ul>
......
...@@ -30,7 +30,7 @@ Performance ...@@ -30,7 +30,7 @@ Performance
<br /><a name="performance_comparison"></a> <br /><a name="performance_comparison"></a>
<h2>Performance Comparison</h2> <h2>Performance Comparison</h2>
<p> <p>
In most cases H2 is a lot faster than all other In many cases H2 is a lot faster than other
(open source and not open source) database engines. (open source and not open source) database engines.
Please note this is mostly a single connection benchmark run on one computer. Please note this is mostly a single connection benchmark run on one computer.
</p> </p>
...@@ -93,7 +93,7 @@ One situation where is H2 is slow is large result sets, because they are buffere ...@@ -93,7 +93,7 @@ One situation where is H2 is slow is large result sets, because they are buffere
disk if more than a certain number of records are returned. disk if more than a certain number of records are returned.
The advantage of buffering is, there is no limit on the result set size. The advantage of buffering is, there is no limit on the result set size.
The open/close time is almost fixed, because of the file locking protocol: The engine waits The open/close time is almost fixed, because of the file locking protocol: The engine waits
20 ms after opening a database to ensure the database files are not opened by another process. some time after opening a database to ensure the database files are not opened by another process.
</p> </p>
<h4>HSQLDB</h4> <h4>HSQLDB</h4>
...@@ -112,15 +112,15 @@ AND S_W_ID=? AND S_I_ID=OL_I_ID AND S_QUANTITY&lt;? ...@@ -112,15 +112,15 @@ AND S_W_ID=? AND S_I_ID=OL_I_ID AND S_QUANTITY&lt;?
</pre> </pre>
<p> <p>
The PolePosition benchmark also shows that the query optimizer does not do a very good job for some queries. The PolePosition benchmark also shows that the query optimizer does not do a very good job for some queries.
A disadvantage in HSQLDB is the slow startup / shutdown time (currently not listed) when using bigger databases. Another disadvantage of HSQLDB is the slow startup / shutdown time (currently not listed) when using bigger databases.
The reason is, a backup of the database is created whenever the database is opened or closed. The reason is, a backup of the whole data is made whenever the database is opened or closed.
</p> </p>
<h4>Derby</h4> <h4>Derby</h4>
<p> <p>
Version 10.4.2.0 was used for the test. Derby is clearly the slowest embedded database in this test. Version 10.4.2.0 was used for the test. Derby is clearly the slowest embedded database in this test.
This seems to be a structural problem, because all operations are really slow. This seems to be a structural problem, because all operations are really slow.
It will not be easy for the developers of Derby to improve the performance to a reasonable level. It will be hard for the developers of Derby to improve the performance to a reasonable level.
A few problems have been identified: Leaving autocommit on is a problem for Derby. A few problems have been identified: Leaving autocommit on is a problem for Derby.
If it is switched off during the whole test, the results are about 20% better for Derby. If it is switched off during the whole test, the results are about 20% better for Derby.
Derby supports a testing mode (system property derby.system.durability=test) where durability is Derby supports a testing mode (system property derby.system.durability=test) where durability is
...@@ -190,7 +190,7 @@ BenchC is similar to the TPC-C test, but single connection / single threaded. ...@@ -190,7 +190,7 @@ BenchC is similar to the TPC-C test, but single connection / single threaded.
<h4>Comparing Embedded with Server Databases</h4> <h4>Comparing Embedded with Server Databases</h4>
<p> <p>
This is mainly a benchmark for embedded databases (where the application runs in the same This is mainly a benchmark for embedded databases (where the application runs in the same
virtual machine than the database engine). However MySQL and PostgreSQL are not Java virtual machine as the database engine). However MySQL and PostgreSQL are not Java
databases and cannot be embedded into a Java application. databases and cannot be embedded into a Java application.
For the Java databases, both embedded and server modes are tested. For the Java databases, both embedded and server modes are tested.
</p> </p>
...@@ -212,8 +212,7 @@ This benchmark runs three times, but only the last run is measured. ...@@ -212,8 +212,7 @@ This benchmark runs three times, but only the last run is measured.
<h4>Memory Usage</h4> <h4>Memory Usage</h4>
<p> <p>
It is not enough to measure the time taken, the memory usage is important as well. It is not enough to measure the time taken, the memory usage is important as well.
Performance can be improved in databases by using a bigger in-memory cache, Performance can be improved by using a bigger cache, but the amount of memory is limited.
but there is only a limited amount of memory available on the system.
HSQLDB tables are kept fully in memory by default; this benchmark HSQLDB tables are kept fully in memory by default; this benchmark
uses 'disk based' tables for all databases. uses 'disk based' tables for all databases.
Unfortunately, it is not so easy to calculate the memory usage of PostgreSQL Unfortunately, it is not so easy to calculate the memory usage of PostgreSQL
...@@ -254,8 +253,6 @@ This time is not measured currently. ...@@ -254,8 +253,6 @@ This time is not measured currently.
Also, not tested is the time used to create a database and open an existing database. Also, not tested is the time used to create a database and open an existing database.
Here, one (wrapper) connection is opened at the start, Here, one (wrapper) connection is opened at the start,
and for each step a new connection is opened and then closed. and for each step a new connection is opened and then closed.
That means the Open/Close time listed is for opening a connection
if the database is already in use.
</p> </p>
<br /><a name="poleposition_benchmark"></a> <br /><a name="poleposition_benchmark"></a>
......
...@@ -408,6 +408,7 @@ Of course, patches are always welcome, but are not always applied as is. Patches ...@@ -408,6 +408,7 @@ Of course, patches are always welcome, but are not always applied as is. Patches
</li><li>MySQL compatibility: DELETE .. FROM .. USING - See http://dev.mysql.com/doc/refman/5.0/en/delete.html </li><li>MySQL compatibility: DELETE .. FROM .. USING - See http://dev.mysql.com/doc/refman/5.0/en/delete.html
</li><li>Allow to scan index backwards starting with a value (to better support ORDER BY DESC). </li><li>Allow to scan index backwards starting with a value (to better support ORDER BY DESC).
</li><li>Java Service Wrapper: try http://yajsw.sourceforge.net/ </li><li>Java Service Wrapper: try http://yajsw.sourceforge.net/
</li><li>Batch parameter for INSERT, UPDATE, and DELETE, and commit after each batch. See also MySQL DELETE.
</li></ul> </li></ul>
<h2>Not Planned</h2> <h2>Not Planned</h2>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论