提交 55edf736 authored 作者: Thomas Mueller's avatar Thomas Mueller

New system property "h2.serializeJavaObject".

上级 cf4ddbab
......@@ -18,7 +18,9 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>Dylan has translated the H2 Console tool to Korean. Thanks a lot!
<ul><li>New system property "h2.serializeJavaObject" (default: true) that allows to disable
serializing Java objects, so that the objects compareTo and toString methods can be used.
</li><li>Dylan has translated the H2 Console tool to Korean. Thanks a lot!
</li><li>Executing the statement CREATE INDEX IF ALREADY EXISTS if the index already exists
no longer fails for a read only database.
</li><li>MVCC: concurrently updating a row could result in the row to appear deleted in the second connection,
......
......@@ -372,13 +372,13 @@ public class SysProperties {
* <b>If true</b>, values of type OTHER will be stored in serialized form
* and have the semantics of binary data for all operations (such as sorting and conversion to string).
* <br />
* <b>If false</b>, the objects will be serialized only for I/O operations and few other special cases
* <b>If false</b>, the objects will be serialized only for I/O operations and a few other special cases
* (for example when someone tries to get the value in binary form or when comparing objects
* other way than in binary form is impossible).
* that are not comparable otherwise).
* <br />
* If the object implements the Comparable interface, the method compareTo
* If the object implements the Comparable interface, the method compareTo
* will be used for sorting (but only if objects being compared have a common comparable
* super type). Otherwise the objects will be compared by types, and if they are the same by hashCode, and
* super type). Otherwise the objects will be compared by type, and if they are the same by hashCode, and
* if the hash codes are equal, but objects are not, the serialized forms (the byte arrays) are compared.
* <br />
* The string representation of the values use the toString method of object.
......@@ -388,7 +388,7 @@ public class SysProperties {
* and display size.
* <br />
* In embedded mode, no data copying occurs, so the user has to make defensive copy himself before storing,
* to make sure that value object is immutable and will not be modified later.
* or ensure that the value object is immutable.
*/
public static final boolean SERIALIZE_JAVA_OBJECT = Utils.getProperty("h2.serializeJavaObject", true);
......
......@@ -78,6 +78,7 @@ import org.h2.test.jdbc.TestCallableStatement;
import org.h2.test.jdbc.TestCancel;
import org.h2.test.jdbc.TestDatabaseEventListener;
import org.h2.test.jdbc.TestDriver;
import org.h2.test.jdbc.TestJavaObject;
import org.h2.test.jdbc.TestLimitUpdates;
import org.h2.test.jdbc.TestLobApi;
import org.h2.test.jdbc.TestManyJdbcObjects;
......@@ -611,6 +612,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new TestCancel().runTest(this);
new TestDatabaseEventListener().runTest(this);
new TestDriver().runTest(this);
new TestJavaObject().runTest(this);
new TestLimitUpdates().runTest(this);
new TestLobApi().runTest(this);
new TestManyJdbcObjects().runTest(this);
......
......@@ -21,7 +21,8 @@ import org.h2.test.TestAll;
import org.h2.test.TestBase;
/**
* Tests java object values when {@link SysProperties#SERIALIZE_JAVA_OBJECT} property is disabled.
* Tests java object values when SysProperties.SERIALIZE_JAVA_OBJECT property is
* disabled.
*
* @author Sergi Vladykin
*/
......@@ -38,7 +39,7 @@ public class TestJavaObject extends TestBase {
TestAll conf = new TestAll();
conf.traceTest = true;
conf.memory = true;
// conf.networked = true;
// conf.networked = true;
TestBase.createCaller().init(conf).test();
}
......@@ -83,7 +84,8 @@ public class TestJavaObject extends TestBase {
x = o1.hashCode() < o2.hashCode() ? o1 : o2;
}
} else {
int cmp = ((Comparable) o1).compareTo(o2);
@SuppressWarnings("unchecked")
int cmp = ((Comparable<Object>) o1).compareTo(o2);
assertFalse(cmp == 0);
x = cmp < 0 ? o1 : o2;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论