mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-21 08:56:22 +00:00
Support H2database 2.x
This commit is contained in:
+1
-1
@@ -85,7 +85,7 @@
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>2.0.202</version>
|
||||
<version>2.1.210</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>2.0.202</version>
|
||||
<version>2.1.210</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
+2
-1
@@ -10,6 +10,7 @@ final class H2DbExpression extends BasicDbExpression {
|
||||
|
||||
@Override
|
||||
public void bitwise(SpiExpressionRequest request, String propName, BitwiseOp operator, long flags, String compare, long match) {
|
||||
bitwiseFunction(request, propName, operator, compare);
|
||||
String funcName = functionName(operator);
|
||||
request.append(funcName).append("(").append(propName).append(", cast(? as long)) ").append(compare).append(" cast(? as long)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,14 @@ final class EnumToDbIntegerMap extends EnumToDbValueMap<Integer> {
|
||||
addInternal(beanValue, dbValue, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBeanValue(Object dbValue) {
|
||||
if (dbValue instanceof String) {
|
||||
return super.getBeanValue(Integer.parseInt(dbValue.toString()));
|
||||
}
|
||||
return super.getBeanValue(dbValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumToDbIntegerMap add(Object beanValue, String stringDbValue, String name) {
|
||||
try {
|
||||
|
||||
@@ -116,7 +116,8 @@ abstract class EnumToDbValueMap<T> {
|
||||
/**
|
||||
* Return the Bean value given the DB value.
|
||||
*/
|
||||
public Object getBeanValue(T dbValue) {
|
||||
@SuppressWarnings("SuspiciousMethodCalls")
|
||||
public Object getBeanValue(Object dbValue) {
|
||||
if (dbValue == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -125,8 +126,7 @@ abstract class EnumToDbValueMap<T> {
|
||||
beanValue = nameMap.get(dbValue);
|
||||
}
|
||||
if (beanValue == null && !allowNulls) {
|
||||
String msg = "Bean value for " + dbValue + " not found in " + valueMap;
|
||||
throw new IllegalArgumentException(msg);
|
||||
throw new IllegalArgumentException("Bean value for " + dbValue + " not found in " + valueMap);
|
||||
}
|
||||
return beanValue;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ datasource.default=h2
|
||||
|
||||
datasource.h2.username=sa
|
||||
datasource.h2.password=
|
||||
datasource.h2.databaseUrl=jdbc:h2:mem:tests
|
||||
datasource.h2.databaseUrl=jdbc:h2:mem:tests;NON_KEYWORDS=KEY
|
||||
|
||||
datasource.pg.username=sa
|
||||
datasource.pg.password=
|
||||
datasource.pg.databaseUrl=jdbc:h2:mem:tests
|
||||
datasource.pg.databaseUrl=jdbc:h2:mem:tests;NON_KEYWORDS=KEY
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>2.0.202</version>
|
||||
<version>2.1.210</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Test dependencies -->
|
||||
|
||||
@@ -101,7 +101,7 @@ public class PlatformNoGeneratedKeysTest {
|
||||
config.setDatabasePlatform(platform);
|
||||
config.getDataSourceConfig().setUsername("sa");
|
||||
config.getDataSourceConfig().setPassword("");
|
||||
config.getDataSourceConfig().setUrl("jdbc:h2:mem:withPCQuery;");
|
||||
config.getDataSourceConfig().setUrl("jdbc:h2:mem:withPCQuery;MODE=LEGACY");
|
||||
config.getDataSourceConfig().setDriver("org.h2.Driver");
|
||||
|
||||
config.setDisableLazyLoading(true);
|
||||
|
||||
@@ -47,6 +47,14 @@ public class ScalarTypeLocalDateTest {
|
||||
assertTrue(o instanceof Date);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void olderDates_ToFromJdbcType() {
|
||||
LocalDate localDate = LocalDate.of(1850,12,1);
|
||||
Object o = type.toJdbcType(localDate);
|
||||
LocalDate localDate1 = type.toBeanType(o);
|
||||
assertThat(localDate1).isEqualTo(localDate);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToBeanType() {
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class TestSqlUpdateUpsert extends BaseTestCase {
|
||||
.setParameter("online", false);
|
||||
|
||||
Object key2 = sqlUpdate2.executeGetKey();
|
||||
assertThat(key2).isNull();
|
||||
assertThat(key2).isEqualTo(key);
|
||||
|
||||
|
||||
EPersonOnline found2 = DB.find(EPersonOnline.class).where().eq("email", email).findOne();
|
||||
|
||||
@@ -8,5 +8,5 @@ ebean.jodaLocalTimeMode=normal
|
||||
|
||||
datasource.someotherdb.username=sa
|
||||
datasource.someotherdb.password=
|
||||
datasource.someotherdb.databaseUrl=jdbc:h2:mem:someotherdb
|
||||
datasource.someotherdb.databaseUrl=jdbc:h2:mem:someotherdb;NON_KEYWORDS=KEY,VALUE
|
||||
datasource.someotherdb.databaseDriver=org.h2.Driver
|
||||
|
||||
Reference in New Issue
Block a user