mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Compare commits
81
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04ff5e7995 | ||
|
|
f490116572 | ||
|
|
6e163b9f5c | ||
|
|
63336bafe5 | ||
|
|
97ca198b7c | ||
|
|
88fd59e164 | ||
|
|
5b9ef2daec | ||
|
|
514bba4130 | ||
|
|
d31aa2b24c | ||
|
|
d834817dc2 | ||
|
|
4cad515110 | ||
|
|
aa89df5f00 | ||
|
|
29f7375468 | ||
|
|
3e4d7c9b5a | ||
|
|
fa34c39d92 | ||
|
|
ffeb630e7e | ||
|
|
7666775d1a | ||
|
|
f95212eeb3 | ||
|
|
5c3b680c8a | ||
|
|
c8bb3c7b57 | ||
|
|
dcd3bfee4c | ||
|
|
b85bb5f459 | ||
|
|
426d314e63 | ||
|
|
e3e5414157 | ||
|
|
28088a5e54 | ||
|
|
2acdf2f4bf | ||
|
|
785a027dd6 | ||
|
|
88005dbe09 | ||
|
|
88acd8190a | ||
|
|
72963bc9fb | ||
|
|
6a552cd7d1 | ||
|
|
c40b9738d1 | ||
|
|
84a64f9640 | ||
|
|
e4c06432a0 | ||
|
|
f58d6038c7 | ||
|
|
f270c52c00 | ||
|
|
e6ea85a193 | ||
|
|
17f408681c | ||
|
|
fcf6f5f384 | ||
|
|
d98c49e266 | ||
|
|
79213e7194 | ||
|
|
bc1f7040da | ||
|
|
f157c2da7f | ||
|
|
33b18fb837 | ||
|
|
1f8a6b0668 | ||
|
|
85a971323a | ||
|
|
f1b626a182 | ||
|
|
cc043316ee | ||
|
|
c656436d09 | ||
|
|
250e66819b | ||
|
|
3e4cc3b3d6 | ||
|
|
f1950d479e | ||
|
|
00686fcccf | ||
|
|
4fe8ef2b23 | ||
|
|
baddc76961 | ||
|
|
de4140aaac | ||
|
|
66aa772f4a | ||
|
|
f745cfaab3 | ||
|
|
8640b4a1a0 | ||
|
|
5e87706055 | ||
|
|
0d765d6583 | ||
|
|
2a924d8d32 | ||
|
|
04d2a20945 | ||
|
|
4077d906d1 | ||
|
|
7e3fbbba62 | ||
|
|
3db9a17c6a | ||
|
|
327babbfa2 | ||
|
|
0a1acb3f9b | ||
|
|
a2e27b9e00 | ||
|
|
a8ad93823a | ||
|
|
5eb790e54d | ||
|
|
c44ae96e09 | ||
|
|
d540bf4d16 | ||
|
|
ab6f5daec3 | ||
|
|
d7a7ef097b | ||
|
|
8f746196ab | ||
|
|
eb1ed0bdd0 | ||
|
|
37ab71cb7c | ||
|
|
74720a840d | ||
|
|
923f83cafb | ||
|
|
2faaf5f186 |
@@ -1,5 +1,5 @@
|
||||
|
||||
name: JDK EA
|
||||
name: ebean EA
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
@@ -11,6 +11,15 @@
|
||||
[](https://github.com/ebean-orm/ebean/actions/workflows/sqlserver.yml)
|
||||
[](https://github.com/ebean-orm/ebean/actions/workflows/yugabyte.yml)
|
||||
|
||||
|
||||
#### Builds against EA (Early Access) versions of Java (19, Loom, panama etc)
|
||||
|
||||
[](https://github.com/ebean-orm/ebean/actions/workflows/jdk-ea.yml)
|
||||
[](https://github.com/ebean-orm/ebean-datasource/actions/workflows/jdk-ea.yml)
|
||||
[](https://github.com/ebean-orm/ebean-migration/actions/workflows/jdk-ea.yml)
|
||||
[](https://github.com/ebean-orm/ebean-test-docker/actions/workflows/jdk-ea.yml)
|
||||
|
||||
|
||||
# Sponsors
|
||||
<table>
|
||||
<tbody>
|
||||
@@ -39,15 +48,15 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
# Need help?
|
||||
## Need help?
|
||||
Post questions or issues to the Ebean google group - https://groups.google.com/forum/#!forum/ebean
|
||||
|
||||
# Documentation
|
||||
## Documentation
|
||||
Goto [https://ebean.io/docs/](https://ebean.io/docs/)
|
||||
|
||||
|
||||
## Maven central links:
|
||||
[Maven central - ebean](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22io.ebean%22%20AND%20a%3A%22ebean%22 "maven central ebean")
|
||||
## Maven central
|
||||
[Maven central - io.ebean](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22io.ebean%22%20)
|
||||
|
||||
|
||||
[Maven central - all related projects](http://search.maven.org/#search%7Cga%7C1%7Cebean "maven central all related projects")
|
||||
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</parent>
|
||||
|
||||
<name>ebean api</name>
|
||||
@@ -49,7 +49,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-annotation</artifactId>
|
||||
<version>7.6</version>
|
||||
<version>7.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -300,7 +300,7 @@ public interface Database {
|
||||
* Create a new instance of T that is an EntityBean.
|
||||
* <p>
|
||||
* Useful if you use BeanPostConstructListeners or @PostConstruct Annotations.
|
||||
* In this case you should not use "new Bean...()". Making all bean construtors protected
|
||||
* In this case you should not use "new Bean...()". Making all bean constructors protected
|
||||
* could be a good idea here.
|
||||
* </p>
|
||||
*/
|
||||
|
||||
@@ -246,6 +246,16 @@ public interface SqlQuery extends Serializable, CancelableQuery {
|
||||
*/
|
||||
SqlQuery setParameter(Object value);
|
||||
|
||||
/**
|
||||
* Set a null parameter by position.
|
||||
*/
|
||||
SqlQuery setNullParameter(int position, int jdbcType);
|
||||
|
||||
/**
|
||||
* Set a null parameter by name.
|
||||
*/
|
||||
SqlQuery setNullParameter(String name, int jdbcType);
|
||||
|
||||
/**
|
||||
* Bind the parameter by its index position (1 based like JDBC).
|
||||
* <p>
|
||||
|
||||
@@ -117,7 +117,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
try {
|
||||
if (set == null) {
|
||||
if (!disableLazyLoad && modifyListening) {
|
||||
lazyLoadCollection(true);
|
||||
lazyLoadCollection(false);
|
||||
} else {
|
||||
set = new LinkedHashSet<>();
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
if (disableLazyLoad) {
|
||||
set = new LinkedHashSet<>();
|
||||
} else {
|
||||
lazyLoadCollection(true);
|
||||
lazyLoadCollection(false);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
||||
@@ -184,17 +184,4 @@ public class DbConstraintNaming {
|
||||
return normalise.normaliseColumn(tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lower case the table name checking for quoted identifiers.
|
||||
*/
|
||||
public String lowerTableName(String tableName) {
|
||||
return normalise.lowerTableName(tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lower case the column name checking for quoted identifiers.
|
||||
*/
|
||||
public String lowerColumnName(String name) {
|
||||
return normalise.lowerColumnName(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,53 +55,19 @@ public class DbConstraintNormalise {
|
||||
return value.replace("(","").replace(")","");
|
||||
}
|
||||
|
||||
/**
|
||||
* Lower case the table name checking for quoted identifiers.
|
||||
*/
|
||||
public String lowerTableName(String tableName) {
|
||||
if (lowerCaseTables && notQuoted(tableName)) {
|
||||
return tableName.toLowerCase();
|
||||
}
|
||||
return tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lower case the column name checking for quoted identifiers.
|
||||
*/
|
||||
public String lowerColumnName(String name) {
|
||||
if (lowerCaseColumns && notQuoted(name)) {
|
||||
return name.toLowerCase();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim off the platform quoted identifier quotes like [ ' and ".
|
||||
*/
|
||||
public boolean notQuoted(String tableName) {
|
||||
public String trimQuotes(String identifier) {
|
||||
|
||||
// remove quoted identifier characters
|
||||
for (String quotedIdentifier : quotedIdentifiers) {
|
||||
if (tableName.contains(quotedIdentifier)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim off the platform quoted identifier quotes like [ ' and ".
|
||||
*/
|
||||
public String trimQuotes(String tableName) {
|
||||
|
||||
if (tableName == null) {
|
||||
if (identifier == null) {
|
||||
return "";
|
||||
}
|
||||
// remove quoted identifier characters
|
||||
for (String quotedIdentifier : quotedIdentifiers) {
|
||||
tableName = tableName.replace(quotedIdentifier, "");
|
||||
identifier = identifier.replace(quotedIdentifier, "");
|
||||
}
|
||||
return tableName;
|
||||
return identifier;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ public class DatabasePlatform {
|
||||
* want to use quoted identifiers for. The backticks get converted to the
|
||||
* appropriate characters in convertQuotedIdentifiers
|
||||
*/
|
||||
private static final char BACK_TICK = '`';
|
||||
private static final char[] QUOTED_IDENTIFIERS = new char[] { '"', '\'', '[', ']', '`' };
|
||||
|
||||
/**
|
||||
* The non-escaped like clause (to stop slash being escaped on some platforms).
|
||||
@@ -662,8 +662,8 @@ public class DatabasePlatform {
|
||||
public String convertQuotedIdentifiers(String dbName) {
|
||||
// Ignore null values e.g. schema name or catalog
|
||||
if (dbName != null && !dbName.isEmpty()) {
|
||||
if (dbName.charAt(0) == BACK_TICK) {
|
||||
if (dbName.charAt(dbName.length() - 1) == BACK_TICK) {
|
||||
if (isQuote(dbName.charAt(0))) {
|
||||
if (isQuote(dbName.charAt(dbName.length() - 1))) {
|
||||
return openQuote + dbName.substring(1, dbName.length() - 1) + closeQuote;
|
||||
} else {
|
||||
log.error("Missing backquote on [" + dbName + "]");
|
||||
@@ -675,6 +675,15 @@ public class DatabasePlatform {
|
||||
return dbName;
|
||||
}
|
||||
|
||||
private boolean isQuote(char ch) {
|
||||
for (char identifer : QUOTED_IDENTIFIERS) {
|
||||
if (identifer == ch) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove quoted identifier quotes from the table or column name if present.
|
||||
*/
|
||||
|
||||
@@ -12,11 +12,18 @@ import io.ebean.bean.PersistenceContext;
|
||||
*/
|
||||
public interface JsonBeanReader<T> {
|
||||
|
||||
/**
|
||||
* Read the JSON into given bean. Will update existing properties.
|
||||
*/
|
||||
T read(T target);
|
||||
|
||||
/**
|
||||
* Read the JSON returning a bean.
|
||||
*/
|
||||
T read();
|
||||
|
||||
default T read() {
|
||||
return read(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new reader taking the context from the existing one but using a new JsonParser.
|
||||
*/
|
||||
|
||||
@@ -58,12 +58,60 @@ public interface JsonContext {
|
||||
*/
|
||||
<T> T toBean(Class<T> cls, JsonParser parser, JsonReadOptions options) throws JsonIOException;
|
||||
|
||||
/**
|
||||
* Read json parser input into a given Bean. <br>
|
||||
* Note: This is a kind of "update". Only properties in the json will be modified. Embedded Lists and Maps will become new
|
||||
* instances, so the object identity will not be preserved here.
|
||||
*
|
||||
* @throws JsonIOException When IOException occurs
|
||||
*/
|
||||
<T> void toBean(T target, JsonParser parser) throws JsonIOException;
|
||||
|
||||
/**
|
||||
* Read json parser input into a given Bean additionally using JsonReadOptions.<br>
|
||||
* See {@link #toBean(Class, JsonParser)} for details modified.
|
||||
*
|
||||
* @throws JsonIOException When IOException occurs
|
||||
*/
|
||||
<T> void toBean(T target, JsonParser parser, JsonReadOptions options) throws JsonIOException;
|
||||
|
||||
/**
|
||||
* Read json reader input into a given Bean.<br>
|
||||
* See {@link #toBean(Class, JsonParser)} for details
|
||||
*
|
||||
* @throws JsonIOException When IOException occurs
|
||||
*/
|
||||
<T> void toBean(T target, Reader json) throws JsonIOException;
|
||||
|
||||
/**
|
||||
* Read json reader input into a given Bean additionally using JsonReadOptions.<br>
|
||||
* See {@link #toBean(Class, JsonParser)} for details modified.
|
||||
*
|
||||
* @throws JsonIOException When IOException occurs
|
||||
*/
|
||||
<T> void toBean(T target, Reader json, JsonReadOptions options) throws JsonIOException;
|
||||
|
||||
/**
|
||||
* Read json string input into a given Bean.<br>
|
||||
* See {@link #toBean(Class, JsonParser)} for details
|
||||
*
|
||||
* @throws JsonIOException When IOException occurs
|
||||
*/
|
||||
<T> void toBean(T target, String json) throws JsonIOException;
|
||||
|
||||
/**
|
||||
* Read json string input into a given Bean additionally using JsonReadOptions.<br>
|
||||
* See {@link #toBean(Class, JsonParser)} for details
|
||||
*
|
||||
* @throws JsonIOException When IOException occurs
|
||||
*/
|
||||
<T> void toBean(T target, String json, JsonReadOptions options) throws JsonIOException;
|
||||
|
||||
/**
|
||||
* Create and return a new bean reading for the bean type given the JSON options and source.
|
||||
* <p>
|
||||
* Note that JsonOption provides an option for setting a persistence context and also enabling
|
||||
* further lazy loading. Further lazy loading requires a persistence context so if that is set
|
||||
* on then a persistence context is created if there is not one set.
|
||||
* Note that JsonOption provides an option for setting a persistence context and also enabling further lazy loading. Further lazy
|
||||
* loading requires a persistence context so if that is set on then a persistence context is created if there is not one set.
|
||||
*/
|
||||
<T> JsonBeanReader<T> createBeanReader(Class<T> cls, JsonParser parser, JsonReadOptions options) throws JsonIOException;
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@ module io.ebean.api {
|
||||
|
||||
requires transitive java.sql;
|
||||
requires transitive io.avaje.config;
|
||||
requires transitive io.avaje.lang;
|
||||
requires transitive persistence.api;
|
||||
requires transitive io.ebean.annotation;
|
||||
requires transitive io.ebean.datasource.api;
|
||||
requires transitive org.slf4j;
|
||||
|
||||
requires static io.ebean.types;
|
||||
requires static io.avaje.jsr305x;
|
||||
requires static com.fasterxml.jackson.core;
|
||||
requires static javax.servlet.api;
|
||||
requires static com.h2database;
|
||||
@@ -41,6 +41,7 @@ module io.ebean.api {
|
||||
exports io.ebean.config.dbplatform.sqlanywhere;
|
||||
exports io.ebean.config.dbplatform.sqlite;
|
||||
exports io.ebean.config.dbplatform.sqlserver;
|
||||
exports io.ebean.config.dbplatform.yugabyte;
|
||||
exports io.ebean.event;
|
||||
exports io.ebean.event.readaudit;
|
||||
exports io.ebean.event.changelog;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package io.ebean;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class DbPrimaryTest {
|
||||
|
||||
@Test
|
||||
void testIsSkipPrimaryServer() {
|
||||
DbPrimary.setSkip(true);
|
||||
assertTrue(DbPrimary.isSkip());
|
||||
DbPrimary.setSkip(false);
|
||||
assertFalse(DbPrimary.isSkip());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetPrimaryServerName() {
|
||||
assertEquals("h2", DbPrimary.getDefaultServerName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLoadProperties() {
|
||||
Properties properties = DbPrimary.getProperties();
|
||||
assertFalse(properties.isEmpty());
|
||||
}
|
||||
}
|
||||
+1
-40
@@ -1,8 +1,5 @@
|
||||
package io.ebean.config.dbplatform;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.annotation.ForPlatform;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.MatchingNamingConvention;
|
||||
@@ -12,45 +9,9 @@ import io.ebean.config.dbplatform.postgres.PostgresPlatform;
|
||||
import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class DatabasePlatformTest extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
@ForPlatform(Platform.H2)
|
||||
public void h2_platform() {
|
||||
final Platform platform = DB.getDefault().platform();
|
||||
assertThat(platform).isSameAs(Platform.H2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ForPlatform(Platform.POSTGRES)
|
||||
public void postgres_platform() {
|
||||
final Platform platform = DB.getDefault().platform().base();
|
||||
assertThat(platform).isSameAs(Platform.POSTGRES);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ForPlatform(Platform.MYSQL)
|
||||
public void mysql_platform() {
|
||||
final Platform platform = DB.getDefault().platform().base();
|
||||
assertThat(platform).isSameAs(Platform.MYSQL);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ForPlatform(Platform.MARIADB)
|
||||
public void mariadb_platform() {
|
||||
final Platform platform = DB.getDefault().platform().base();
|
||||
assertThat(platform).isSameAs(Platform.MARIADB);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ForPlatform(Platform.SQLSERVER)
|
||||
public void sqlserver_platform() {
|
||||
final Platform platform = DB.getDefault().platform().base();
|
||||
assertThat(platform).isSameAs(Platform.SQLSERVER);
|
||||
}
|
||||
class DatabasePlatformTest {
|
||||
|
||||
@Test
|
||||
public void convertQuotedIdentifiers_when_allQuotedIdentifier_sqlServer() {
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package io.ebean.config.dbplatform;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.sql.Types;
|
||||
@@ -13,7 +14,7 @@ public class DbPlatformTypeLookupTest {
|
||||
@Test
|
||||
public void byName() throws Exception {
|
||||
|
||||
assertEquals(lookup.byName("DECIMAL"), DbType.DECIMAL);
|
||||
Assertions.assertEquals(lookup.byName("DECIMAL"), DbType.DECIMAL);
|
||||
assertEquals(lookup.byName("Decimal"), DbType.DECIMAL);
|
||||
assertEquals(lookup.byName("decimal"), DbType.DECIMAL);
|
||||
|
||||
+1
-44
@@ -1,25 +1,12 @@
|
||||
package io.ebean.text;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.FetchPath;
|
||||
import io.ebean.Query;
|
||||
import io.ebean.test.LoggedSql;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.tests.model.basic.Customer;
|
||||
import org.tests.model.basic.ResetBasicData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class PathPropertiesTests extends BaseTestCase {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PathPropertiesTests.class);
|
||||
public class PathPropertiesTests {
|
||||
|
||||
@Test
|
||||
public void test_noParentheses() {
|
||||
@@ -197,34 +184,4 @@ public class PathPropertiesTests extends BaseTestCase {
|
||||
assertFalse(root.includesPath("customer", "shippingAddress"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void example_withQueryAndJson() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
PathProperties pathProps = PathProperties.parse("id,name,billingAddress(city),shippingAddress(*))");
|
||||
|
||||
Query<Customer> query = DB.find(Customer.class)
|
||||
.where().lt("id", 2)
|
||||
.query();
|
||||
|
||||
pathProps.apply(query);
|
||||
|
||||
List<Customer> list = query.findList();
|
||||
|
||||
String asJson = DB.json().toJson(list, pathProps);
|
||||
log.info("Json: {}", asJson);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_withAllPropsQuery() {
|
||||
PathProperties root = PathProperties.parse("*,billingAddress(line1)");
|
||||
LoggedSql.start();
|
||||
Query<Customer> query = DB.find(Customer.class).apply(root);
|
||||
query.findList();
|
||||
List<String> sql = LoggedSql.stop();
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains("select t0.id, t0.status, t0.name, t0.smallnote, t0.anniversary, t0.cretime, t0.updtime, t0.version, t0.shipping_address_id, t1.id, t1.line_1 from o_customer t0 left join o_address t1 on t1.id = t0.billing_address_id;");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
datasource.default=h2
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</parent>
|
||||
<!-- <parent>-->
|
||||
<!-- <groupId>org.avaje</groupId>-->
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
<scm>
|
||||
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
|
||||
<tag>ebean-parent-12.16.0</tag>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<name>ebean autotune</name>
|
||||
@@ -26,7 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
+15
-15
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</parent>
|
||||
|
||||
<name>ebean bom</name>
|
||||
@@ -71,88 +71,88 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core-type</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-ddl-generator</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-externalmapping-api</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-externalmapping-xml</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-autotune</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>querybean-generator</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>kotlin-querybean-generator</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-test</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-postgis</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-redis</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ebean-core-type</artifactId>
|
||||
@@ -16,7 +16,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
+5
-5
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ebean-core</artifactId>
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
<scm>
|
||||
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
|
||||
<tag>ebean-parent-12.16.0</tag>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
@@ -41,19 +41,19 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core-type</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-externalmapping-api</artifactId>
|
||||
<version>12.16.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -167,7 +167,7 @@ public final class BindParams implements Serializable {
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void setParameter(int position, Object value) {
|
||||
assert value != null : "use setNullParameter";
|
||||
//TODO: Review - assert value != null : "use setNullParameter";
|
||||
Param p = getParam(position);
|
||||
if (value instanceof Collection) {
|
||||
// use of postgres ANY with positioned parameter
|
||||
@@ -219,7 +219,7 @@ public final class BindParams implements Serializable {
|
||||
* Set a named In parameter that is not null.
|
||||
*/
|
||||
public Param setParameter(String name, Object value) {
|
||||
assert value != null : "use setNullParameter";
|
||||
// TODO: Review - assert value != null : "use setNullParameter";
|
||||
Param p = getParam(name);
|
||||
p.setInValue(value);
|
||||
return p;
|
||||
|
||||
@@ -35,7 +35,7 @@ public final class CacheIdLookupMany<T> implements CacheIdLookup<T> {
|
||||
@Override
|
||||
public List<T> removeHits(BeanCacheResult<T> cacheResult) {
|
||||
Set<Object> hitIds = new HashSet<>();
|
||||
List<T> beans = new ArrayList<>(hitIds.size());
|
||||
List<T> beans = new ArrayList<>();
|
||||
for (BeanCacheResult.Entry<T> hit : cacheResult.hits()) {
|
||||
hitIds.add(hit.getKey());
|
||||
beans.add(hit.getBean());
|
||||
|
||||
@@ -97,8 +97,12 @@ public final class LoadManyRequest extends LoadRequest {
|
||||
// potentially changes the joins, selected properties, cache mode
|
||||
loadContext.configureQuery(query);
|
||||
if (onlyIds) {
|
||||
// lazy loading invoked via clear() and removeAll()
|
||||
query.select(many.targetIdProperty());
|
||||
String mapKey = many.mapKey();
|
||||
if (mapKey != null) {
|
||||
query.select(mapKey);
|
||||
} else {
|
||||
query.select(many.targetIdProperty());
|
||||
}
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
@@ -445,6 +445,9 @@ public final class InternalConfiguration {
|
||||
*/
|
||||
private DataTimeZone initDataTimeZone() {
|
||||
String tz = config.getDataTimeZone();
|
||||
if ("NoTimeZone".equals(tz)) {
|
||||
return new NoDataTimeZone();
|
||||
}
|
||||
if (tz == null) {
|
||||
if (isMySql(getPlatform())) {
|
||||
return new MySqlDataTimeZone();
|
||||
|
||||
@@ -121,6 +121,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
private final boolean softDelete;
|
||||
private final String draftTable;
|
||||
private final PartitionMeta partitionMeta;
|
||||
private final TablespaceMeta tablespaceMeta;
|
||||
private final String storageEngine;
|
||||
private final String dbComment;
|
||||
private final boolean readAuditing;
|
||||
@@ -275,6 +276,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
this.dependentTables = deploy.getDependentTables();
|
||||
this.dbComment = deploy.getDbComment();
|
||||
this.partitionMeta = deploy.getPartitionMeta();
|
||||
this.tablespaceMeta = deploy.getTablespaceMeta();
|
||||
this.storageEngine = deploy.getStorageEngine();
|
||||
this.autoTunable = beanFinder == null && (entityType == EntityType.ORM || entityType == EntityType.VIEW);
|
||||
// helper object used to derive lists of properties
|
||||
@@ -2671,6 +2673,13 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
public PartitionMeta partitionMeta() {
|
||||
return partitionMeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the tablespace details of the bean.
|
||||
*/
|
||||
public TablespaceMeta tablespaceMeta() {
|
||||
return tablespaceMeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the storage engine.
|
||||
@@ -3372,12 +3381,12 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
jsonHelp.jsonWriteProperties(writeJson, bean);
|
||||
}
|
||||
|
||||
public T jsonRead(SpiJsonReader jsonRead, String path) throws IOException {
|
||||
return jsonHelp.jsonRead(jsonRead, path, true);
|
||||
public T jsonRead(SpiJsonReader jsonRead, String path, T target) throws IOException {
|
||||
return jsonHelp.jsonRead(jsonRead, path, true, target);
|
||||
}
|
||||
|
||||
T jsonReadObject(SpiJsonReader jsonRead, String path) throws IOException {
|
||||
return jsonHelp.jsonRead(jsonRead, path, false);
|
||||
T jsonReadObject(SpiJsonReader jsonRead, String path, T target) throws IOException {
|
||||
return jsonHelp.jsonRead(jsonRead, path, false, target);
|
||||
}
|
||||
|
||||
public List<BeanProperty[]> uniqueProps() {
|
||||
|
||||
+4
-4
@@ -61,13 +61,13 @@ class BeanDescriptorElementEmbedded<T> extends BeanDescriptorElement<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T jsonRead(SpiJsonReader jsonRead, String path) throws IOException {
|
||||
return readJsonElement(jsonRead, path);
|
||||
public T jsonRead(SpiJsonReader jsonRead, String path, T target) throws IOException {
|
||||
return readJsonElement(jsonRead, path, target);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
T readJsonElement(SpiJsonReader jsonRead, String path) throws IOException {
|
||||
return (T)targetDescriptor.jsonRead(jsonRead, path);
|
||||
T readJsonElement(SpiJsonReader jsonRead, String path, T target) throws IOException {
|
||||
return (T)targetDescriptor.jsonRead(jsonRead, path, target);
|
||||
}
|
||||
|
||||
void writeJsonElement(SpiJsonWriter ctx, Object element) {
|
||||
|
||||
+2
-2
@@ -58,13 +58,13 @@ class BeanDescriptorElementEmbeddedMap<T> extends BeanDescriptorElementEmbedded<
|
||||
}
|
||||
if (stringKey) {
|
||||
parser.nextToken();
|
||||
Object val = readJsonElement(readJson, null);
|
||||
Object val = readJsonElement(readJson, null, null); // CHECKME: Update existing map entry here?
|
||||
add.addKeyValue(fieldName, val);
|
||||
} else {
|
||||
parser.nextFieldName();
|
||||
Object key = scalarTypeKey.jsonRead(parser);
|
||||
parser.nextFieldName();
|
||||
Object val = readJsonElement(readJson, null);
|
||||
Object val = readJsonElement(readJson, null, null); // CHECKME: Update existing map entry here?
|
||||
add.addKeyValue(key, val);
|
||||
}
|
||||
} while (true);
|
||||
|
||||
+14
-6
@@ -65,7 +65,7 @@ final class BeanDescriptorJsonHelp<T> {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
T jsonRead(SpiJsonReader jsonRead, String path, boolean withInheritance) throws IOException {
|
||||
T jsonRead(SpiJsonReader jsonRead, String path, boolean withInheritance, T target) throws IOException {
|
||||
JsonParser parser = jsonRead.getParser();
|
||||
//noinspection StatementWithEmptyBody
|
||||
if (parser.getCurrentToken() == JsonToken.START_OBJECT) {
|
||||
@@ -82,7 +82,7 @@ final class BeanDescriptorJsonHelp<T> {
|
||||
}
|
||||
|
||||
if (desc.inheritInfo == null || !withInheritance) {
|
||||
return jsonReadObject(jsonRead, path);
|
||||
return jsonReadObject(jsonRead, path, target);
|
||||
}
|
||||
|
||||
ObjectNode node = jsonRead.getObjectMapper().readTree(parser);
|
||||
@@ -97,17 +97,25 @@ final class BeanDescriptorJsonHelp<T> {
|
||||
JsonNode discNode = node.get(discColumn);
|
||||
if (discNode == null || discNode.isNull()) {
|
||||
if (!desc.isAbstractType()) {
|
||||
return desc.jsonReadObject(newReader, path);
|
||||
return desc.jsonReadObject(newReader, path, target);
|
||||
}
|
||||
String msg = "Error reading inheritance discriminator - expected [" + discColumn + "] but no json key?";
|
||||
throw new JsonParseException(newParser, msg, parser.getCurrentLocation());
|
||||
}
|
||||
|
||||
return (T) inheritInfo.readType(discNode.asText()).desc().jsonReadObject(newReader, path);
|
||||
BeanDescriptor<T> inheritDesc = (BeanDescriptor<T>) inheritInfo.readType(discNode.asText()).desc();
|
||||
return inheritDesc.jsonReadObject(newReader, path, target);
|
||||
}
|
||||
|
||||
private T jsonReadObject(SpiJsonReader readJson, String path) throws IOException {
|
||||
EntityBean bean = desc.createEntityBeanForJson();
|
||||
private T jsonReadObject(SpiJsonReader readJson, String path, T target) throws IOException {
|
||||
EntityBean bean;
|
||||
if (target == null) {
|
||||
bean = desc.createEntityBeanForJson();
|
||||
} else if (desc.beanType.isInstance(target)) {
|
||||
bean = (EntityBean) target;
|
||||
} else {
|
||||
throw new ClassCastException(target.getClass().getName() + " provided, but " + desc.beanType.getClass().getName() + " expected");
|
||||
}
|
||||
return jsonReadProperties(readJson, bean, path);
|
||||
}
|
||||
|
||||
|
||||
@@ -1004,7 +1004,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
* Return the DB column default to use for DDL.
|
||||
*/
|
||||
public String dbColumnDefault() {
|
||||
return dbColumnDefn != null ? null : dbColumnDefault;
|
||||
return dbColumnDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1016,7 +1016,8 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
BeanCollection<?> collection = createEmpty(parentBean);
|
||||
BeanCollectionAdd add = beanCollectionAdd(collection);
|
||||
do {
|
||||
EntityBean detailBean = (EntityBean) targetDescriptor.jsonRead(readJson, name);
|
||||
// CHECKME: Update existing list entry here?
|
||||
EntityBean detailBean = (EntityBean) targetDescriptor.jsonRead(readJson, name, null);
|
||||
if (detailBean == null) {
|
||||
// read the entire array
|
||||
break;
|
||||
|
||||
@@ -783,7 +783,8 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
@Override
|
||||
public void jsonRead(SpiJsonReader readJson, EntityBean bean) throws IOException {
|
||||
if (jsonDeserialize && targetDescriptor != null) {
|
||||
T assocBean = targetDescriptor.jsonRead(readJson, name);
|
||||
T target = (T) value(bean);
|
||||
T assocBean = targetDescriptor.jsonRead(readJson, name, target);
|
||||
setValue(bean, assocBean);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Meta data for table spaces. If table space is configured, tablespaceName, indexTablespace, lobTablespace is never null;
|
||||
*
|
||||
* @author Noemi Szemenyei, FOCONIS AG
|
||||
*
|
||||
*/
|
||||
public final class TablespaceMeta {
|
||||
|
||||
private final String tablespaceName;
|
||||
private final String indexTablespace;
|
||||
private final String lobTablespace;
|
||||
|
||||
public TablespaceMeta(String tablespaceName, String indexTablespace, String lobTablespace) {
|
||||
this.tablespaceName = tablespaceName;
|
||||
this.indexTablespace = indexTablespace;
|
||||
this.lobTablespace = lobTablespace;
|
||||
}
|
||||
|
||||
public String getTablespaceName() {
|
||||
return tablespaceName;
|
||||
}
|
||||
|
||||
public String getIndexTablespace() {
|
||||
return indexTablespace;
|
||||
}
|
||||
|
||||
public String getLobTablespace() {
|
||||
return lobTablespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(indexTablespace, tablespaceName, lobTablespace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
TablespaceMeta other = (TablespaceMeta) obj;
|
||||
return Objects.equals(indexTablespace, other.indexTablespace)
|
||||
&& Objects.equals(tablespaceName, other.tablespaceName)
|
||||
&& Objects.equals(lobTablespace, other.lobTablespace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "tablespace=" + tablespaceName + ", indexTablespace=" + indexTablespace + ", lobTablespace=" + lobTablespace;
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -32,6 +32,7 @@ import io.ebeaninternal.server.deploy.IndexDefinition;
|
||||
import io.ebeaninternal.server.deploy.InheritInfo;
|
||||
import io.ebeaninternal.server.deploy.PartitionMeta;
|
||||
import io.ebeaninternal.server.deploy.TableJoin;
|
||||
import io.ebeaninternal.server.deploy.TablespaceMeta;
|
||||
import io.ebeaninternal.server.deploy.parse.DeployBeanInfo;
|
||||
import io.ebeaninternal.server.idgen.UuidV1IdGenerator;
|
||||
import io.ebeaninternal.server.idgen.UuidV1RndIdGenerator;
|
||||
@@ -135,6 +136,7 @@ public class DeployBeanDescriptor<T> {
|
||||
private ChangeLogFilter changeLogFilter;
|
||||
private String dbComment;
|
||||
private PartitionMeta partitionMeta;
|
||||
private TablespaceMeta tablespaceMeta;
|
||||
/**
|
||||
* One of NONE, INDEX or EMBEDDED.
|
||||
*/
|
||||
@@ -252,6 +254,14 @@ public class DeployBeanDescriptor<T> {
|
||||
}
|
||||
return partitionMeta;
|
||||
}
|
||||
|
||||
public void setTablespaceMeta(TablespaceMeta tablespaceMeta) {
|
||||
this.tablespaceMeta = tablespaceMeta;
|
||||
}
|
||||
|
||||
public TablespaceMeta getTablespaceMeta() {
|
||||
return tablespaceMeta;
|
||||
}
|
||||
|
||||
public void setDraftable() {
|
||||
draftable = true;
|
||||
|
||||
@@ -12,6 +12,7 @@ import io.ebean.annotation.Index;
|
||||
import io.ebean.annotation.InvalidateQueryCache;
|
||||
import io.ebean.annotation.ReadAudit;
|
||||
import io.ebean.annotation.StorageEngine;
|
||||
import io.ebean.annotation.Tablespace;
|
||||
import io.ebean.annotation.View;
|
||||
import io.ebean.config.TableName;
|
||||
import io.ebeaninternal.api.CoreLog;
|
||||
@@ -19,6 +20,7 @@ import io.ebeaninternal.server.deploy.BeanDescriptor.EntityType;
|
||||
import io.ebeaninternal.server.deploy.IndexDefinition;
|
||||
import io.ebeaninternal.server.deploy.InheritInfo;
|
||||
import io.ebeaninternal.server.deploy.PartitionMeta;
|
||||
import io.ebeaninternal.server.deploy.TablespaceMeta;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployBeanProperty;
|
||||
|
||||
import javax.persistence.AttributeOverride;
|
||||
@@ -154,6 +156,18 @@ final class AnnotationClass extends AnnotationParser {
|
||||
if (partition != null) {
|
||||
descriptor.setPartitionMeta(new PartitionMeta(partition.mode(), partition.property()));
|
||||
}
|
||||
Tablespace tablespace = typeGet(cls, Tablespace.class);
|
||||
if (tablespace != null) {
|
||||
String indexTs = tablespace.index();
|
||||
if("".equals(indexTs)) {
|
||||
indexTs = tablespace.value();
|
||||
}
|
||||
String lobTs = tablespace.lob();
|
||||
if("".equals(lobTs)) {
|
||||
lobTs = tablespace.value();
|
||||
}
|
||||
descriptor.setTablespaceMeta(new TablespaceMeta(tablespace.value(), indexTs, lobTs));
|
||||
}
|
||||
Draftable draftable = typeGet(cls, Draftable.class);
|
||||
if (draftable != null) {
|
||||
descriptor.setDraftable();
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ abstract class AbstractTextExpression extends AbstractExpression {
|
||||
@Override
|
||||
public void queryBindKey(BindValuesKey key) {
|
||||
// do nothing, only execute against document store
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameByBind(SpiExpression other) {
|
||||
|
||||
@@ -4,8 +4,6 @@ import io.ebeaninternal.api.BindValuesKey;
|
||||
import io.ebeaninternal.api.SpiExpression;
|
||||
import io.ebeaninternal.api.SpiExpressionRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Bitwise expression.
|
||||
*/
|
||||
@@ -25,7 +23,7 @@ final class BitwiseExpression extends AbstractExpression {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
public void writeDocQuery(DocQueryContext context) {
|
||||
throw new IllegalStateException("Not supported for document queries");
|
||||
}
|
||||
|
||||
|
||||
+6
-8
@@ -47,12 +47,12 @@ final class DefaultExampleExpression implements SpiExpression, ExampleExpression
|
||||
private final EntityBean entity;
|
||||
|
||||
/**
|
||||
* Set to true to use case insensitive expressions.
|
||||
* Set to true to use case-insensitive expressions.
|
||||
*/
|
||||
private boolean caseInsensitive;
|
||||
|
||||
/**
|
||||
* The type of like (RAW, STARTS_WITH, ENDS_WITH etc)
|
||||
* The type of like (RAW, STARTS_WITH, ENDS_WITH)
|
||||
*/
|
||||
private LikeType likeType;
|
||||
|
||||
@@ -62,7 +62,7 @@ final class DefaultExampleExpression implements SpiExpression, ExampleExpression
|
||||
private boolean includeZeros;
|
||||
|
||||
/**
|
||||
* The non null bean properties and found and together added as a list of
|
||||
* The non-null bean properties and found and together added as a list of
|
||||
* expressions (like or equal to expressions).
|
||||
*/
|
||||
private ArrayList<SpiExpression> list;
|
||||
@@ -71,8 +71,8 @@ final class DefaultExampleExpression implements SpiExpression, ExampleExpression
|
||||
/**
|
||||
* Construct the query by example expression.
|
||||
*
|
||||
* @param entity the example entity with non null property values
|
||||
* @param caseInsensitive if true use case insensitive expressions
|
||||
* @param entity the example entity with non-null property values
|
||||
* @param caseInsensitive if true use case-insensitive expressions
|
||||
* @param likeType the type of Like wild card used
|
||||
*/
|
||||
DefaultExampleExpression(EntityBean entity, boolean caseInsensitive, LikeType likeType) {
|
||||
@@ -303,9 +303,7 @@ final class DefaultExampleExpression implements SpiExpression, ExampleExpression
|
||||
*/
|
||||
private boolean isZero(Object value) {
|
||||
if (value instanceof Number) {
|
||||
if (((Number) value).doubleValue() == 0) {
|
||||
return true;
|
||||
}
|
||||
return ((Number) value).doubleValue() == 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
+13
-13
@@ -186,7 +186,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
|
||||
/**
|
||||
* Case Insensitive Equal To - property equal to the given value (typically
|
||||
* using a lower() function to make it case insensitive).
|
||||
* using a lower() function to make it case-insensitive).
|
||||
*/
|
||||
@Override
|
||||
public Expression ieq(String propertyName, String value) {
|
||||
@@ -198,7 +198,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
|
||||
/**
|
||||
* Case Insensitive Equal To - property equal to the given value (typically
|
||||
* using a lower() function to make it case insensitive).
|
||||
* using a lower() function to make it case-insensitive).
|
||||
*/
|
||||
@Override
|
||||
public Expression ine(String propertyName, String value) {
|
||||
@@ -336,7 +336,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Case insensitive {@link #exampleLike(Object)}
|
||||
* Case-insensitive {@link #exampleLike(Object)}
|
||||
*/
|
||||
@Override
|
||||
public ExampleExpression iexampleLike(Object example) {
|
||||
@@ -344,7 +344,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the query by Example expression which is case sensitive and using
|
||||
* Create the query by Example expression which is case-sensitive and using
|
||||
* LikeType.RAW (you need to add you own wildcards % and _).
|
||||
*/
|
||||
@Override
|
||||
@@ -375,9 +375,9 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Case insensitive Like - property like value where the value contains the
|
||||
* SQL wild card characters % (percentage) and _ (underscore). Typically uses
|
||||
* a lower() function to make the expression case insensitive.
|
||||
* Case-insensitive Like - property like value where the value contains the
|
||||
* SQL wild card characters % (percentage) and _ (underscore). Typically, uses
|
||||
* a lower() function to make the expression case-insensitive.
|
||||
*/
|
||||
@Override
|
||||
public Expression ilike(String propertyName, String value) {
|
||||
@@ -397,8 +397,8 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Case insensitive Starts With - property like value%. Typically uses a
|
||||
* lower() function to make the expression case insensitive.
|
||||
* Case-insensitive Starts With - property like value%. Typically, uses a
|
||||
* lower() function to make the expression case-insensitive.
|
||||
*/
|
||||
@Override
|
||||
public Expression istartsWith(String propertyName, String value) {
|
||||
@@ -414,8 +414,8 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Case insensitive Ends With - property like %value. Typically uses a lower()
|
||||
* function to make the expression case insensitive.
|
||||
* Case-insensitive Ends With - property like %value. Typically, uses a lower()
|
||||
* function to make the expression case-insensitive.
|
||||
*/
|
||||
@Override
|
||||
public Expression iendsWith(String propertyName, String value) {
|
||||
@@ -431,8 +431,8 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Case insensitive Contains - property like %value%. Typically uses a lower()
|
||||
* function to make the expression case insensitive.
|
||||
* Case-insensitive Contains - property like %value%. Typically, uses a lower()
|
||||
* function to make the expression case-insensitive.
|
||||
*/
|
||||
@Override
|
||||
public Expression icontains(String propertyName, String value) {
|
||||
|
||||
+1
-1
@@ -162,7 +162,7 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
writeDocQuery(context, null);
|
||||
|
||||
} else {
|
||||
// this is a Top level "text" expressions so we may need to wrap in Bool SHOULD etc.
|
||||
// this is a Top level "text" expressions, so we may need to wrap in Bool SHOULD etc.
|
||||
if (list.isEmpty()) {
|
||||
throw new IllegalStateException("empty expression list?");
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public interface DocQueryContext {
|
||||
void writeIn(String propertyName, Object[] values, boolean not) throws IOException;
|
||||
|
||||
/**
|
||||
* Write an Id in expression.
|
||||
* Write an ID in expression.
|
||||
*/
|
||||
void writeIds(Collection<?> idCollection) throws IOException;
|
||||
|
||||
@@ -131,7 +131,7 @@ public interface DocQueryContext {
|
||||
void writeTextQueryString(String search, TextQueryString options) throws IOException;
|
||||
|
||||
/**
|
||||
* Start a Bool which may contain some of Must, Must Not, Should.
|
||||
* Start a Bool which may contain Must, Must Not, Should.
|
||||
*/
|
||||
void startBoolGroup() throws IOException;
|
||||
|
||||
|
||||
+3
-11
@@ -1,19 +1,11 @@
|
||||
package io.ebeaninternal.server.expression;
|
||||
|
||||
import io.ebean.event.BeanQueryRequest;
|
||||
import io.ebeaninternal.api.BindValuesKey;
|
||||
import io.ebeaninternal.api.ManyWhereJoins;
|
||||
import io.ebeaninternal.api.NaturalKeyQueryData;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.api.SpiExpression;
|
||||
import io.ebeaninternal.api.SpiExpressionRequest;
|
||||
import io.ebeaninternal.api.SpiExpressionValidation;
|
||||
import io.ebeaninternal.api.SpiQuery;
|
||||
import io.ebeaninternal.api.*;
|
||||
import io.ebeaninternal.api.SpiQuery.Type;
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import io.ebeaninternal.server.query.CQuery;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
final class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpression {
|
||||
@@ -52,7 +44,7 @@ final class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreE
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
public void writeDocQuery(DocQueryContext context) {
|
||||
throw new IllegalStateException("Not supported");
|
||||
}
|
||||
|
||||
@@ -77,7 +69,7 @@ final class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreE
|
||||
/**
|
||||
* Compile/build the sub query.
|
||||
*/
|
||||
protected CQuery<?> compileSubQuery(BeanQueryRequest<?> queryRequest) {
|
||||
CQuery<?> compileSubQuery(BeanQueryRequest<?> queryRequest) {
|
||||
SpiEbeanServer ebeanServer = (SpiEbeanServer) queryRequest.database();
|
||||
return ebeanServer.compileQuery(Type.SQ_EXISTS, subQuery, queryRequest.transaction());
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ final class IdExpression extends NonPrepareExpression implements SpiExpression {
|
||||
@Override
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
|
||||
// 'flatten' EmbeddedId and multiple Id cases
|
||||
// 'flatten' EmbeddedId and multiple ID cases
|
||||
// into an array of the underlying scalar field values
|
||||
DefaultExpressionRequest r = (DefaultExpressionRequest) request;
|
||||
Object[] bindIdValues = r.getBeanDescriptor().bindIdValues(value);
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Id IN expression common for cache handling.
|
||||
* ID IN expression common for cache handling.
|
||||
*/
|
||||
public interface IdInCommon {
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* In a collection of Id values.
|
||||
* In a collection of ID values.
|
||||
*/
|
||||
public final class IdInExpression extends NonPrepareExpression implements IdInCommon {
|
||||
|
||||
@@ -73,7 +73,7 @@ public final class IdInExpression extends NonPrepareExpression implements IdInCo
|
||||
if (idCollection.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// Bind the Id values including EmbeddedId and multiple Id
|
||||
// Bind the ID values including EmbeddedId and multiple ID
|
||||
|
||||
DefaultExpressionRequest r = (DefaultExpressionRequest) request;
|
||||
BeanDescriptor<?> descriptor = r.getBeanDescriptor();
|
||||
@@ -82,7 +82,7 @@ public final class IdInExpression extends NonPrepareExpression implements IdInCo
|
||||
}
|
||||
|
||||
/**
|
||||
* For use with deleting non attached detail beans during stateless update.
|
||||
* For use with deleting non-attached detail beans during stateless update.
|
||||
*/
|
||||
public void addSqlNoAlias(SpiExpressionRequest request) {
|
||||
|
||||
@@ -116,7 +116,7 @@ public final class IdInExpression extends NonPrepareExpression implements IdInCo
|
||||
}
|
||||
|
||||
/**
|
||||
* Incorporates the number of Id values to bind.
|
||||
* Incorporates the number of ID values to bind.
|
||||
*/
|
||||
@Override
|
||||
public void queryPlanHash(StringBuilder builder) {
|
||||
|
||||
@@ -9,7 +9,6 @@ import io.ebeaninternal.api.SpiExpression;
|
||||
import io.ebeaninternal.api.SpiExpressionRequest;
|
||||
import io.ebeaninternal.server.persist.MultiValueWrapper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -54,7 +53,7 @@ final class InPairsExpression extends AbstractExpression {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
public void writeDocQuery(DocQueryContext context) {
|
||||
throw new RuntimeException("Not supported with document query");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
package io.ebeaninternal.server.expression;
|
||||
|
||||
import io.ebean.event.BeanQueryRequest;
|
||||
import io.ebeaninternal.api.BindValuesKey;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.api.SpiExpression;
|
||||
import io.ebeaninternal.api.SpiExpressionRequest;
|
||||
import io.ebeaninternal.api.SpiQuery;
|
||||
import io.ebeaninternal.api.*;
|
||||
import io.ebeaninternal.api.SpiQuery.Type;
|
||||
import io.ebeaninternal.server.query.CQuery;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -42,7 +37,7 @@ final class InQueryExpression extends AbstractExpression implements UnsupportedD
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
public void writeDocQuery(DocQueryContext context) {
|
||||
throw new IllegalStateException("Not supported");
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ final class IsEmptyExpression extends AbstractExpression {
|
||||
}
|
||||
}
|
||||
|
||||
public final String getPropName() {
|
||||
public String getPropName() {
|
||||
return propName;
|
||||
}
|
||||
|
||||
|
||||
@@ -868,7 +868,7 @@ final class JunctionExpression<T> implements SpiJunction<T>, SpiExpression, Expr
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> select(FetchGroup fetchGroup) {
|
||||
public Query<T> select(FetchGroup<T> fetchGroup) {
|
||||
return exprList.select(fetchGroup);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A logical And or Or for joining two expressions.
|
||||
* A logical And or, Or for joining two expressions.
|
||||
*/
|
||||
abstract class LogicExpression implements SpiExpression {
|
||||
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
package io.ebeaninternal.server.expression;
|
||||
|
||||
import io.ebean.event.BeanQueryRequest;
|
||||
import io.ebeaninternal.api.BindValuesKey;
|
||||
import io.ebeaninternal.api.ManyWhereJoins;
|
||||
import io.ebeaninternal.api.NaturalKeyQueryData;
|
||||
import io.ebeaninternal.api.SpiExpression;
|
||||
import io.ebeaninternal.api.SpiExpressionRequest;
|
||||
import io.ebeaninternal.api.SpiExpressionValidation;
|
||||
import io.ebeaninternal.api.*;
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Effectively an expression that has no effect.
|
||||
*/
|
||||
@@ -40,7 +33,7 @@ final class NoopExpression implements SpiExpression {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
public void writeDocQuery(DocQueryContext context) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-4
@@ -16,7 +16,7 @@ final class RawExpressionBuilder {
|
||||
*/
|
||||
static RawExpression buildSingle(String raw, Object value) {
|
||||
if (isExpand(value, raw, BP_1)) {
|
||||
Collection val = (Collection) value;
|
||||
Collection<?> val = (Collection<?>) value;
|
||||
raw = raw.replace(BP_1, expand(val));
|
||||
return new RawExpression(raw, val.toArray());
|
||||
}
|
||||
@@ -50,8 +50,7 @@ final class RawExpressionBuilder {
|
||||
return "?" + (i + 1);
|
||||
}
|
||||
|
||||
private static String expand(Collection values) {
|
||||
|
||||
private static String expand(Collection<?> values) {
|
||||
StringBuilder sqlExpand = new StringBuilder(values.size() * 2);
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
if (i > 0) {
|
||||
@@ -72,7 +71,7 @@ final class RawExpressionBuilder {
|
||||
if (!isExpand(values[i], raw, match)) {
|
||||
params.add(values[i]);
|
||||
} else {
|
||||
Collection val = (Collection) values[i];
|
||||
Collection<?> val = (Collection<?>) values[i];
|
||||
params.addAll(val);
|
||||
raw = raw.replace(match, expand(val));
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Objects;
|
||||
final class Same {
|
||||
|
||||
/**
|
||||
* Return true if both values are null or both an not null.
|
||||
* Return true if both values are null or both not null.
|
||||
*/
|
||||
static boolean sameByNull(Object v1, Object v2) {
|
||||
return (v1 == null) == (v2 == null);
|
||||
|
||||
@@ -55,7 +55,7 @@ public final class SimpleExpression extends AbstractValueExpression {
|
||||
}
|
||||
}
|
||||
|
||||
public final String getPropName() {
|
||||
public String getPropName() {
|
||||
return propName;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ Expressions for building WHERE clauses.
|
||||
<p>
|
||||
In the code above the LIKE and GREATER THAN Expressions are added to the where clause.
|
||||
The way this works is that where() returns an ExpressionList which has methods on
|
||||
it to create the standard expressions (EQUAL TO, LIKE etc).
|
||||
it to create the standard expressions (EQUAL TO, LIKE etc.)
|
||||
</p>
|
||||
<p>
|
||||
I expect most people to add their expressions in this way. The Expr expression factory
|
||||
|
||||
+12
@@ -119,6 +119,18 @@ public final class DefaultRelationalQuery extends AbstractQuery implements SpiSq
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlQuery setNullParameter(int position, int jdbcType) {
|
||||
bindParams.setNullParameter(position, jdbcType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlQuery setNullParameter(String name, int jdbcType) {
|
||||
bindParams.setNullParameter(name, jdbcType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultRelationalQuery setParameter(int position, Object value) {
|
||||
bindParams.setParameter(position, value);
|
||||
|
||||
@@ -36,9 +36,9 @@ public final class DJsonBeanReader<T> implements JsonBeanReader<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T read() {
|
||||
public T read(T target) {
|
||||
try {
|
||||
return desc.jsonRead(readJson, null);
|
||||
return desc.jsonRead(readJson, null, target);
|
||||
} catch (IOException e) {
|
||||
throw new PersistenceIOException(e);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,43 @@ public final class DJsonContext implements SpiJsonContext {
|
||||
|
||||
BeanDescriptor<T> desc = getDescriptor(cls);
|
||||
try {
|
||||
return desc.jsonRead(new ReadJson(desc, parser, options, determineObjectMapper(options)), null);
|
||||
return desc.jsonRead(new ReadJson(desc, parser, options, determineObjectMapper(options)), null, null);
|
||||
} catch (IOException e) {
|
||||
throw new JsonIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void toBean(T target, String json) throws JsonIOException {
|
||||
toBean(target, new StringReader(json));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void toBean(T target, String json, JsonReadOptions options) throws JsonIOException {
|
||||
toBean(target, new StringReader(json), options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void toBean(T target, Reader jsonReader) throws JsonIOException {
|
||||
toBean(target, createParser(jsonReader));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void toBean(T target, Reader jsonReader, JsonReadOptions options) throws JsonIOException {
|
||||
toBean(target, createParser(jsonReader), options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void toBean(T target, JsonParser parser) throws JsonIOException {
|
||||
toBean(target, parser, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void toBean(T target, JsonParser parser, JsonReadOptions options) throws JsonIOException {
|
||||
|
||||
BeanDescriptor<T> desc = (BeanDescriptor<T>) getDescriptor(target.getClass());
|
||||
try {
|
||||
desc.jsonRead(new ReadJson(desc, parser, options, determineObjectMapper(options)), null, target);
|
||||
} catch (IOException e) {
|
||||
throw new JsonIOException(e);
|
||||
}
|
||||
@@ -188,7 +224,8 @@ public final class DJsonContext implements SpiJsonContext {
|
||||
|
||||
List<T> list = new ArrayList<>();
|
||||
do {
|
||||
T bean = desc.jsonRead(readJson, null);
|
||||
// CHECKME: Should we update the list
|
||||
T bean = desc.jsonRead(readJson, null, null);
|
||||
if (bean == null) {
|
||||
break;
|
||||
} else {
|
||||
|
||||
@@ -34,28 +34,28 @@ public class RsetDataReader implements DataReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushJson(String json) {
|
||||
public final void pushJson(String json) {
|
||||
this.json = json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String popJson() {
|
||||
public final String popJson() {
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws SQLException {
|
||||
public final void close() throws SQLException {
|
||||
rset.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean next() throws SQLException {
|
||||
public final boolean next() throws SQLException {
|
||||
pos = 0;
|
||||
return rset.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementPos(int increment) {
|
||||
public final void incrementPos(int increment) {
|
||||
pos += increment;
|
||||
}
|
||||
|
||||
@@ -64,49 +64,49 @@ public class RsetDataReader implements DataReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array getArray() throws SQLException {
|
||||
public final Array getArray() throws SQLException {
|
||||
return rset.getArray(pos());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject() throws SQLException {
|
||||
public final Object getObject() throws SQLException {
|
||||
return rset.getObject(pos());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getObject(Class<T> cls) throws SQLException {
|
||||
public final <T> T getObject(Class<T> cls) throws SQLException {
|
||||
return rset.getObject(pos(), cls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getBigDecimal() throws SQLException {
|
||||
public final BigDecimal getBigDecimal() throws SQLException {
|
||||
return rset.getBigDecimal(pos());
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getBinaryStream() throws SQLException {
|
||||
public final InputStream getBinaryStream() throws SQLException {
|
||||
return rset.getBinaryStream(pos());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getBoolean() throws SQLException {
|
||||
public final Boolean getBoolean() throws SQLException {
|
||||
boolean v = rset.getBoolean(pos());
|
||||
return rset.wasNull() ? null : v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Byte getByte() throws SQLException {
|
||||
public final Byte getByte() throws SQLException {
|
||||
byte v = rset.getByte(pos());
|
||||
return rset.wasNull() ? null : v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws SQLException {
|
||||
public final byte[] getBytes() throws SQLException {
|
||||
return rset.getBytes(pos());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getDate() throws SQLException {
|
||||
public final Date getDate() throws SQLException {
|
||||
Calendar cal = dataTimeZone.getDateTimeZone();
|
||||
if (cal != null) {
|
||||
return rset.getDate(pos(), cal);
|
||||
@@ -116,46 +116,46 @@ public class RsetDataReader implements DataReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getDouble() throws SQLException {
|
||||
public final Double getDouble() throws SQLException {
|
||||
double v = rset.getDouble(pos());
|
||||
return rset.wasNull() ? null : v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float getFloat() throws SQLException {
|
||||
public final Float getFloat() throws SQLException {
|
||||
float v = rset.getFloat(pos());
|
||||
return rset.wasNull() ? null : v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getInt() throws SQLException {
|
||||
public final Integer getInt() throws SQLException {
|
||||
int v = rset.getInt(pos());
|
||||
return rset.wasNull() ? null : v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getLong() throws SQLException {
|
||||
public final Long getLong() throws SQLException {
|
||||
long v = rset.getLong(pos());
|
||||
return rset.wasNull() ? null : v;
|
||||
}
|
||||
|
||||
public Ref getRef() throws SQLException {
|
||||
public final Ref getRef() throws SQLException {
|
||||
return rset.getRef(pos());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getShort() throws SQLException {
|
||||
public final Short getShort() throws SQLException {
|
||||
short s = rset.getShort(pos());
|
||||
return rset.wasNull() ? null : s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString() throws SQLException {
|
||||
public final String getString() throws SQLException {
|
||||
return rset.getString(pos());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Time getTime() throws SQLException {
|
||||
public final Time getTime() throws SQLException {
|
||||
Calendar cal = dataTimeZone.getTimeZone();
|
||||
if (cal != null) {
|
||||
return rset.getTime(pos(), cal);
|
||||
@@ -165,7 +165,7 @@ public class RsetDataReader implements DataReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Timestamp getTimestamp() throws SQLException {
|
||||
public final Timestamp getTimestamp() throws SQLException {
|
||||
Calendar cal = dataTimeZone.getTimeZone();
|
||||
if (cal != null) {
|
||||
return rset.getTimestamp(pos(), cal);
|
||||
@@ -175,12 +175,12 @@ public class RsetDataReader implements DataReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStringFromStream() throws SQLException {
|
||||
public final String getStringFromStream() throws SQLException {
|
||||
Reader reader = rset.getCharacterStream(pos());
|
||||
return reader == null ? null : readStringLob(reader);
|
||||
}
|
||||
|
||||
protected String readStringLob(Reader reader) throws SQLException {
|
||||
private String readStringLob(Reader reader) throws SQLException {
|
||||
char[] buffer = new char[clobBufferSize];
|
||||
int readLength;
|
||||
StringBuilder out = new StringBuilder(stringInitialSize);
|
||||
@@ -196,12 +196,12 @@ public class RsetDataReader implements DataReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBinaryBytes() throws SQLException {
|
||||
public final byte[] getBinaryBytes() throws SQLException {
|
||||
InputStream in = rset.getBinaryStream(pos());
|
||||
return getBinaryLob(in);
|
||||
}
|
||||
|
||||
protected byte[] getBinaryLob(InputStream in) throws SQLException {
|
||||
private byte[] getBinaryLob(InputStream in) throws SQLException {
|
||||
if (in == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -38,13 +38,13 @@ module io.ebean.core {
|
||||
requires static org.postgresql.jdbc;
|
||||
requires static joda.time;
|
||||
|
||||
exports io.ebeaninternal.api;
|
||||
exports io.ebeaninternal.server.cache;
|
||||
// export these for io.ebean.ddl.generator (but that becomes unnamed module in maven test scope)
|
||||
exports io.ebeaninternal.server.deploy;
|
||||
exports io.ebeaninternal.server.deploy.visitor;
|
||||
// exports io.ebeaninternal.server.deploy to io.ebean.autotune, io.ebean.ddl.generator;
|
||||
// exports io.ebeaninternal.server.deploy.visitor to io.ebean.ddl.generator;
|
||||
|
||||
exports io.ebeaninternal.api to io.ebean.ddl.generator, io.ebean.querybean, io.ebean.autotune, io.ebean.postgis, io.ebean.test;
|
||||
exports io.ebeaninternal.server.deploy to io.ebean.autotune, io.ebean.ddl.generator;
|
||||
exports io.ebeaninternal.server.deploy.id to io.ebean.ddl.generator;
|
||||
exports io.ebeaninternal.server.deploy.meta to io.ebean.ddl.generator;
|
||||
exports io.ebeaninternal.server.deploy.visitor to io.ebean.ddl.generator;
|
||||
|
||||
exports io.ebeaninternal.server.el to io.ebean.autotune;
|
||||
exports io.ebeaninternal.server.autotune to io.ebean.autotune;
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
package io.ebeaninternal.server.cache;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.bean.PersistenceContext;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
@@ -20,12 +20,12 @@ import java.sql.Timestamp;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
public class CacheBeanDataTest extends BaseTestCase {
|
||||
public class CacheBeanDataTest {
|
||||
|
||||
@Test
|
||||
public void extract_load_on_customer() {
|
||||
|
||||
SpiEbeanServer server = spiEbeanServer();
|
||||
SpiEbeanServer server = (SpiEbeanServer)DB.getDefault();
|
||||
BeanDescriptor<Customer> desc = server.descriptor(Customer.class);
|
||||
|
||||
Customer c = new Customer();
|
||||
@@ -77,7 +77,7 @@ public class CacheBeanDataTest extends BaseTestCase {
|
||||
@Test
|
||||
public void extract_load_withEmbeddedBean() {
|
||||
|
||||
SpiEbeanServer server = spiEbeanServer();
|
||||
SpiEbeanServer server = (SpiEbeanServer)DB.getDefault();
|
||||
BeanDescriptor<EPerson> desc = server.descriptor(EPerson.class);
|
||||
BeanPropertyAssocOne<?> addressBeanProperty = (BeanPropertyAssocOne<?>) desc.beanProperty("address");
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
package io.ebeaninternal.server.cache;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
@@ -17,9 +17,9 @@ import java.util.Map;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class CachedBeanDataFromBeanTest extends BaseTestCase {
|
||||
public class CachedBeanDataFromBeanTest {
|
||||
|
||||
private final SpiEbeanServer server = spiEbeanServer();
|
||||
private final SpiEbeanServer server = (SpiEbeanServer)DB.getDefault();
|
||||
|
||||
@Test
|
||||
public void extract() {
|
||||
@@ -84,7 +84,7 @@ public class CachedBeanDataFromBeanTest extends BaseTestCase {
|
||||
// mutate, dirty
|
||||
contact.setLastName("Banana");
|
||||
|
||||
final BeanDescriptor<Contact> desc = getBeanDescriptor(Contact.class);
|
||||
final BeanDescriptor<Contact> desc = server.descriptor(Contact.class);
|
||||
CachedBeanData cacheData = CachedBeanDataFromBean.extract(desc, entityBean);
|
||||
|
||||
final Map<String, Object> data = cacheData.getData();
|
||||
@@ -115,7 +115,7 @@ public class CachedBeanDataFromBeanTest extends BaseTestCase {
|
||||
contact.setCustomer(customer2);
|
||||
contact.setLastName("Banana");
|
||||
|
||||
final BeanDescriptor<Contact> desc = getBeanDescriptor(Contact.class);
|
||||
final BeanDescriptor<Contact> desc = server.descriptor(Contact.class);
|
||||
CachedBeanData cacheData = CachedBeanDataFromBean.extract(desc, entityBean);
|
||||
|
||||
final Map<String, Object> data = cacheData.getData();
|
||||
+10
-14
@@ -1,27 +1,26 @@
|
||||
package io.ebeaninternal.server.cache;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import io.ebeaninternal.server.transaction.DefaultPersistenceContext;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.Customer;
|
||||
import org.tests.model.basic.ResetBasicData;
|
||||
import org.tests.model.basic.TBytesOnly;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class CachedBeanDataSerializeTest {
|
||||
|
||||
public class CachedBeanDataSerializeTest extends BaseTestCase {
|
||||
private final SpiEbeanServer db = (SpiEbeanServer)DB.getDefault();
|
||||
|
||||
@Test
|
||||
public void write() throws IOException, ClassNotFoundException {
|
||||
@@ -58,16 +57,13 @@ public class CachedBeanDataSerializeTest extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void fullBean() throws IOException, ClassNotFoundException {
|
||||
Customer customer = new Customer();
|
||||
customer.setId(42);
|
||||
customer.setName("FooBar");
|
||||
customer.setStatus(Customer.Status.INACTIVE);
|
||||
customer.setVersion(3L);
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
List<Customer> customers = DB.find(Customer.class)
|
||||
.order().asc("id")
|
||||
.setMaxRows(1).findList();
|
||||
|
||||
Customer customer = customers.get(0);
|
||||
|
||||
BeanDescriptor<Customer> desc = getBeanDescriptor(Customer.class);
|
||||
BeanDescriptor<Customer> desc = db.descriptor(Customer.class);
|
||||
CachedBeanData extract = CachedBeanDataFromBean.extract(desc, (EntityBean) customer);
|
||||
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
@@ -97,7 +93,7 @@ public class CachedBeanDataSerializeTest extends BaseTestCase {
|
||||
bean.setId(42);
|
||||
bean.setContent(stringContent.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
BeanDescriptor<TBytesOnly> desc = getBeanDescriptor(TBytesOnly.class);
|
||||
BeanDescriptor<TBytesOnly> desc = db.descriptor(TBytesOnly.class);
|
||||
CachedBeanData extract = CachedBeanDataFromBean.extract(desc, (EntityBean) bean);
|
||||
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
+2
-3
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.server.changelog;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.event.changelog.BeanChange;
|
||||
import io.ebean.event.changelog.ChangeSet;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -11,12 +10,12 @@ import java.util.List;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
public class ChangeJsonBuilderTest extends BaseTestCase {
|
||||
class ChangeJsonBuilderTest {
|
||||
|
||||
Helper helper = new Helper();
|
||||
|
||||
@Test
|
||||
public void testToJson() throws Exception {
|
||||
void testToJson() throws Exception {
|
||||
|
||||
ChangeJsonBuilder builder = new ChangeJsonBuilder();
|
||||
|
||||
+4
-7
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.server.changelog;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.event.changelog.ChangeLogFilter;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.inheritance.model.ProductConfiguration;
|
||||
@@ -12,11 +11,10 @@ import org.tests.model.basic.Customer;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class DefaultChangeLogRegisterTest extends BaseTestCase {
|
||||
|
||||
class DefaultChangeLogRegisterTest {
|
||||
|
||||
@Test
|
||||
public void test_defaultInsertTrue() {
|
||||
void test_defaultInsertTrue() {
|
||||
|
||||
DefaultChangeLogRegister register = new DefaultChangeLogRegister(true);
|
||||
|
||||
@@ -39,7 +37,7 @@ public class DefaultChangeLogRegisterTest extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_defaultInsertFalse() {
|
||||
void test_defaultInsertFalse() {
|
||||
|
||||
DefaultChangeLogRegister register = new DefaultChangeLogRegister(false);
|
||||
|
||||
@@ -62,8 +60,7 @@ public class DefaultChangeLogRegisterTest extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_inheritance() {
|
||||
|
||||
void test_inheritance() {
|
||||
DefaultChangeLogRegister register = new DefaultChangeLogRegister(true);
|
||||
ChangeLogFilter changeFilter = register.getChangeFilter(ProductConfiguration.class);
|
||||
assertNotNull(changeFilter);
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package io.ebeaninternal.server.core;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
@@ -9,7 +10,7 @@ public class BasicTypeConverterTest {
|
||||
|
||||
@Test
|
||||
public void toBoolean_when_1_long() throws Exception {
|
||||
assertTrue(BasicTypeConverter.toBoolean(1L, "T"));
|
||||
Assertions.assertTrue(BasicTypeConverter.toBoolean(1L, "T"));
|
||||
}
|
||||
|
||||
@Test
|
||||
+6
-2
@@ -1,8 +1,8 @@
|
||||
package io.ebeaninternal.server.core;
|
||||
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.Database;
|
||||
import io.ebean.FetchConfig;
|
||||
import io.ebean.Query;
|
||||
import io.ebeaninternal.server.querydefn.DefaultOrmQuery;
|
||||
@@ -12,12 +12,16 @@ import org.tests.model.basic.Order;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
public class DefaultServer_createOrmQueryRequestTest {
|
||||
|
||||
Query<Order> query() {
|
||||
return server().find(Order.class);
|
||||
}
|
||||
|
||||
private Database server() {
|
||||
return DB.getDefault();
|
||||
}
|
||||
|
||||
OrmQueryRequest<Order> queryRequest(Query<Order> query) {
|
||||
return OrmQueryRequestTestHelper.queryRequest(query);
|
||||
}
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package io.ebeaninternal.server.core;
|
||||
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
@@ -10,7 +11,7 @@ public class DtoQueryRequestTest {
|
||||
@Test
|
||||
public void testParse() {
|
||||
|
||||
assertEquals("foo", DtoQueryRequest.parseColumn("foo"));
|
||||
Assertions.assertEquals("foo", DtoQueryRequest.parseColumn("foo"));
|
||||
assertEquals("bar", DtoQueryRequest.parseColumn("zx__t0_bar"));
|
||||
assertEquals("BAR", DtoQueryRequest.parseColumn("ZX__T0_BAR"));
|
||||
assertEquals("baz", DtoQueryRequest.parseColumn("zx__t42_baz"));
|
||||
+5
-7
@@ -4,16 +4,14 @@ import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.datasource.DataSourceAlert;
|
||||
import io.ebean.datasource.DataSourceConfig;
|
||||
import io.ebean.datasource.pool.ConnectionPool;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
public class InitDataSourceTest {
|
||||
|
||||
private DatabaseConfig newConfig(String readOnlyUrl) {
|
||||
@@ -129,8 +127,8 @@ public class InitDataSourceTest {
|
||||
assertNotNull(roConfig);
|
||||
assertEquals("foo", roConfig.getUrl());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void online() {
|
||||
DatabaseConfig config = new DatabaseConfig();
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.server.core;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.Database;
|
||||
import io.ebean.ValuePair;
|
||||
@@ -19,7 +18,7 @@ import java.util.Set;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class TestDiffHelpSimple extends BaseTestCase {
|
||||
class TestDiffHelpSimple {
|
||||
|
||||
long firstTime = System.currentTimeMillis() - 10000;
|
||||
long secondTime = System.currentTimeMillis();
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.server.core;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.Database;
|
||||
import io.ebean.ValuePair;
|
||||
@@ -14,7 +13,7 @@ import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestDiffHelpWithEmbedded extends BaseTestCase {
|
||||
public class TestDiffHelpWithEmbedded {
|
||||
|
||||
Database server;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import io.ebean.DB;
|
||||
import io.ebean.Database;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import org.tests.model.basic.Animal;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
public class BaseTest {
|
||||
|
||||
protected SpiEbeanServer db = (SpiEbeanServer)DB.getDefault();
|
||||
|
||||
protected <T> BeanDescriptor<T> getBeanDescriptor(Class<T> cls) {
|
||||
return db.descriptor(cls);
|
||||
}
|
||||
|
||||
protected SpiEbeanServer spiEbeanServer() {
|
||||
return db;
|
||||
}
|
||||
|
||||
protected Database server() {
|
||||
return db;
|
||||
}
|
||||
|
||||
protected void initTables() {
|
||||
try {
|
||||
db.find(Animal.class).findCount();
|
||||
} catch (PersistenceException e) {
|
||||
db.script().run("/h2-init.sql");
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isH2() {
|
||||
return isPlatform(Platform.H2);
|
||||
}
|
||||
protected boolean isPostgres() {
|
||||
return isPlatform(Platform.POSTGRES);
|
||||
}
|
||||
protected boolean isSqlServer() {
|
||||
return isPlatform(Platform.SQLSERVER);
|
||||
}
|
||||
protected boolean isMySql() {
|
||||
return isPlatform(Platform.MYSQL);
|
||||
}
|
||||
protected boolean isPlatform(Platform platform) {
|
||||
return db.platform().base().equals(platform);
|
||||
}
|
||||
}
|
||||
+9
-7
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.plugin.Property;
|
||||
@@ -8,6 +7,7 @@ import io.ebeaninternal.server.core.CacheOptions;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployIdentityMode;
|
||||
import io.ebeanservice.docstore.api.DocStoreBeanAdapter;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.*;
|
||||
import org.tests.model.bridge.BSite;
|
||||
@@ -21,7 +21,7 @@ import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class BeanDescriptorTest extends BaseTestCase {
|
||||
public class BeanDescriptorTest extends BaseTest {
|
||||
|
||||
private BeanDescriptor<Customer> customerDesc = spiEbeanServer().descriptor(Customer.class);
|
||||
|
||||
@@ -30,35 +30,37 @@ public class BeanDescriptorTest extends BaseTestCase {
|
||||
|
||||
Customer bean = customerDesc.createReference(null, false, 42, null);
|
||||
assertThat(bean.getId()).isEqualTo(42);
|
||||
assertThat(server().beanState(bean).isReadOnly()).isFalse();
|
||||
Assertions.assertThat(server().beanState(bean).isReadOnly()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createReference_whenReadOnly() {
|
||||
|
||||
Customer bean = customerDesc.createReference(Boolean.TRUE, false, 42, null);
|
||||
assertThat(server().beanState(bean).isReadOnly()).isTrue();
|
||||
Assertions.assertThat(server().beanState(bean).isReadOnly()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createReference_whenNotReadOnly() {
|
||||
|
||||
Customer bean = customerDesc.createReference(Boolean.FALSE, false, 42, null);
|
||||
assertThat(server().beanState(bean).isReadOnly()).isFalse();
|
||||
Assertions.assertThat(server().beanState(bean).isReadOnly()).isFalse();
|
||||
|
||||
bean = customerDesc.createReference(42, null);
|
||||
assertThat(server().beanState(bean).isReadOnly()).isFalse();
|
||||
Assertions.assertThat(server().beanState(bean).isReadOnly()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createReference_when_disabledLazyLoad() {
|
||||
|
||||
Customer bean = customerDesc.createReference(Boolean.FALSE, true, 42, null);
|
||||
assertThat(server().beanState(bean).isDisableLazyLoad()).isTrue();
|
||||
Assertions.assertThat(server().beanState(bean).isDisableLazyLoad()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createReference_with_inheritance() {
|
||||
initTables();
|
||||
|
||||
Cat cat = new Cat();
|
||||
cat.setName("Puss");
|
||||
DB.save(cat);
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebeanservice.docstore.api.mapping.DocPropertyAdapter;
|
||||
import io.ebeanservice.docstore.api.mapping.DocPropertyMapping;
|
||||
import io.ebeanservice.docstore.api.mapping.DocumentMapping;
|
||||
@@ -9,7 +8,7 @@ import org.tests.model.basic.Order;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class BeanDescriptor_documentMappingTest extends BaseTestCase {
|
||||
public class BeanDescriptor_documentMappingTest extends BaseTest {
|
||||
|
||||
|
||||
@Test
|
||||
+2
-1
@@ -6,6 +6,7 @@ import io.ebean.event.AbstractBeanPersistListener;
|
||||
import io.ebean.event.BeanPersistAdapter;
|
||||
import io.ebean.event.BeanPersistListener;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.EBasic;
|
||||
|
||||
@@ -46,7 +47,7 @@ public class BeanDescriptor_registerTest {
|
||||
Controller2 controller2 = new Controller2();
|
||||
desc.register(controller2);
|
||||
|
||||
assertEquals(2, ((ChainedBeanPersistController) desc.persistController()).size());
|
||||
Assertions.assertEquals(2, ((ChainedBeanPersistController) desc.persistController()).size());
|
||||
|
||||
desc.deregister(controller1);
|
||||
assertEquals(1, ((ChainedBeanPersistController) desc.persistController()).size());
|
||||
+1
-4
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -10,9 +9,7 @@ import org.tests.model.basic.EBasic;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
|
||||
public class BeanDescriptor_whenCreatedPropertyTest extends BaseTestCase {
|
||||
|
||||
public class BeanDescriptor_whenCreatedPropertyTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
+19
-23
@@ -1,23 +1,19 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.bean.BeanCollection;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.common.BeanList;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.Contact;
|
||||
import org.tests.model.basic.Customer;
|
||||
import org.tests.model.basic.ResetBasicData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
|
||||
public class BeanPropertyAssocManyTest extends BaseTestCase {
|
||||
public class BeanPropertyAssocManyTest extends BaseTest {
|
||||
|
||||
private BeanDescriptor<Customer> customerDesc = spiEbeanServer().descriptor(Customer.class);
|
||||
|
||||
@@ -62,22 +58,22 @@ public class BeanPropertyAssocManyTest extends BaseTestCase {
|
||||
assertThat(customer.getContacts().get(0)).isSameAs(contact);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findIdsByParentId() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
List<Long> ids = DB.find(Customer.class).orderBy("id").setMaxRows(2).findIds();
|
||||
|
||||
List<Object> customerIds = new ArrayList<>();
|
||||
customerIds.add(ids.get(0));
|
||||
customerIds.add(ids.get(1));
|
||||
|
||||
List<Object> contactIdsForOne = contacts().findIdsByParentId(ids.get(0), null, null, null, true);
|
||||
|
||||
List<Object> contactIdsForMultiple = contacts().findIdsByParentId(null, customerIds, null, null, true);
|
||||
|
||||
assertThat(contactIdsForOne).isNotEmpty();
|
||||
assertThat(contactIdsForMultiple).isNotEmpty();
|
||||
}
|
||||
// @Test
|
||||
// public void findIdsByParentId() {
|
||||
//
|
||||
// ResetBasicData.reset();
|
||||
//
|
||||
// List<Long> ids = DB.find(Customer.class).orderBy("id").setMaxRows(2).findIds();
|
||||
//
|
||||
// List<Object> customerIds = new ArrayList<>();
|
||||
// customerIds.add(ids.get(0));
|
||||
// customerIds.add(ids.get(1));
|
||||
//
|
||||
// List<Object> contactIdsForOne = contacts().findIdsByParentId(ids.get(0), null, null, null, true);
|
||||
//
|
||||
// List<Object> contactIdsForMultiple = contacts().findIdsByParentId(null, customerIds, null, null, true);
|
||||
//
|
||||
// assertThat(contactIdsForOne).isNotEmpty();
|
||||
// assertThat(contactIdsForMultiple).isNotEmpty();
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.Address;
|
||||
import org.tests.model.basic.BWithQIdent;
|
||||
import org.tests.model.basic.Customer;
|
||||
|
||||
public class DeployPropertyParserTest extends BaseTest {
|
||||
|
||||
private final BeanDescriptor<Customer> descriptor = getBeanDescriptor(Customer.class);
|
||||
|
||||
private final BeanDescriptor<Address> addressBeanDescriptor = getBeanDescriptor(Address.class);
|
||||
|
||||
private final BeanDescriptor<BWithQIdent> bWithQIdentDescriptor = getBeanDescriptor(BWithQIdent.class);
|
||||
|
||||
@Test
|
||||
public void from_prefix_expect_unchanged() {
|
||||
Assertions.assertThat(parser().parse("(select x from status join status)")).isEqualTo("(select x from status join status)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void depth0_path() {
|
||||
Assertions.assertThat(parser().parse("pre status post")).isEqualTo("pre ${}status post");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void depth1_path() {
|
||||
Assertions.assertThat(parser().parse("billingAddress.city")).isEqualTo("${billingAddress}city");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void depth2_path() {
|
||||
Assertions.assertThat(parser().parse("max(billingAddress.country.name)")).isEqualTo("max(${billingAddress.country}name)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleMax() {
|
||||
Assertions.assertThat(parser().parse("max(name)")).isEqualTo("max(${}name)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void combined() {
|
||||
Assertions.assertThat(parser().parse("sum(status * name)")).isEqualTo("sum(${}status * ${}name)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void combined_withAtColumn() {
|
||||
Assertions.assertThat(addressParser().parse("concat(line1, line2, '-EA')")).isEqualTo("concat(${}line_1, ${}line_2, '-EA')");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withExplicitQuote_all_platforms() {
|
||||
Assertions.assertThat(withQuoteParser().parse("t0.`CODE` like ?")).isEqualTo("t0.`CODE` like ?");
|
||||
Assertions.assertThat(withQuoteParser().parse("t0.[CODE] like ?")).isEqualTo("t0.[CODE] like ?");
|
||||
Assertions.assertThat(withQuoteParser().parse("t0.\"CODE\" like ?")).isEqualTo("t0.\"CODE\" like ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withQuote_when_match_h2() {
|
||||
if (isH2() || isPostgres()) {
|
||||
Assertions.assertThat(withQuoteParser().parse("name like ?")).isEqualTo("${}\"Name\" like ?");
|
||||
} else if (isSqlServer()) {
|
||||
Assertions.assertThat(withQuoteParser().parse("name like ?")).isEqualTo("${}[Name] like ?");
|
||||
} else if (isMySql()) {
|
||||
Assertions.assertThat(withQuoteParser().parse("name like ?")).isEqualTo("${}`Name` like ?");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unknown_path() {
|
||||
Assertions.assertThat(parser().parse(" foo ")).isEqualTo(" foo ");
|
||||
}
|
||||
|
||||
private DeployPropertyParser parser() {
|
||||
return descriptor.parser();
|
||||
}
|
||||
|
||||
private DeployPropertyParser addressParser() {
|
||||
return addressBeanDescriptor.parser();
|
||||
}
|
||||
|
||||
private DeployPropertyParser withQuoteParser() {
|
||||
return bWithQIdentDescriptor.parser();
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user