Compare commits

...
Author SHA1 Message Date
Rob Bygrave 8edaabf755 [maven-release-plugin] prepare release ebean-parent-12.14.1 2022-01-17 22:30:53 +13:00
Rob Bygrave 25eea42211 Bump to ebean-migration 12.13.0 and ebean-agent 12.14.1 2022-01-17 22:28:36 +13:00
Rob Bygrave 263f6cdeba Tidy OraclePlatform only 2022-01-17 22:10:53 +13:00
Rob Bygrave 38f1967e60 #2473 - Oracle - column alias - Change such that OraclePlatform doesn't use column alias
So with #2254 we regressed OraclePlatform to use column alias. This really should have introduced an Oracle12 platform instead. 18c onwards and we don't want the column alias.
2022-01-17 22:10:21 +13:00
Rob Bygrave 6eb8eb0dd2 #2473 Tidy BasicSqlAnsiLimiter only, no functional change 2022-01-17 21:58:33 +13:00
Rob Bygrave 1165d857d8 Fix test ParentQueryTest 2022-01-17 21:57:14 +13:00
Rob Bygrave 874c2f5231 #2492 - Fix for Oracle platform when insert only default values 2022-01-17 21:42:09 +13:00
Rob Bygrave 88ab852855 No real change, tidy DbExpressionHandlerFactory only 2022-01-17 21:28:45 +13:00
Rob Bygrave b577331524 #2492 - Fix for Oracle platform when insert only default values 2022-01-17 21:27:42 +13:00
Rob Bygrave ec45fc1c86 Fix tests for Oracle - BITADD in @Where clause expression 2022-01-17 21:26:19 +13:00
Rob Bygrave e65876e8ed #2477 - Add failing test case (disable for the moment) 2022-01-17 20:58:19 +13:00
Rob BygraveandGitHub 5453037172 Merge pull request #2491 from ebean-orm/feature/2476-elementCollectionConstructor
#2476 - Fix for element collection on bean with default constructor
2022-01-17 15:41:33 +13:00
Rob Bygrave 9b116c9bf6 #2476 - tidy tests 2022-01-17 15:38:41 +13:00
Rob Bygrave 82862deccc #2476 - Fix for element collection on bean with default constructor
Note that we can look for a better longer term fix which might would look at treating element collection more like ToMany collections in terms of enhancement.
2022-01-17 15:36:26 +13:00
Rob Bygrave 1c83bbe0b0 #2476 - Failing test for element collection on bean with default constructor 2022-01-17 15:33:13 +13:00
Rob BygraveandGitHub f16f34f35f Merge pull request #2488 from ebean-orm/feature/2487
#2487 - ebean-test support Docker In Docker - docker container's hostname rather than hardcoded "localhost"
2022-01-14 16:32:04 +13:00
Rob Bygrave 38bc5b2fea #2488 - refactor extract logic into DockerHost helper, fix RedisSetup, pass docker host to ebean-test-docker 2022-01-14 16:27:04 +13:00
Rob Bygrave 356dc5eb19 #2487 - ebean-test support Docker In Docker - docker container's hostname rather than hardcoded "localhost" 2022-01-13 15:02:38 +13:00
Rob BygraveandGitHub c5779133bc Merge pull request #2485 from FOCONIS/fix-utf8-problems-with-specialchars
Fix utf8 problems with specialchars
2022-01-13 11:05:27 +13:00
Rob BygraveandGitHub b8b6311348 Merge pull request #2447 from FOCONIS/fix-scalartype-problem2
Traverse class hierarchy, when searching for ScalarType
2022-01-13 10:58:05 +13:00
FOCONIS\szemenyei 8eed983fbb restore old test 2022-01-12 08:37:46 +01:00
Rob BygraveandGitHub 7cfecb83a9 Merge pull request #2486 from bigjimlefou/fixWindows
Fix some tests failing on Windows
2022-01-12 09:17:37 +13:00
bigjimlefou e92939a34d Fix failing test on Windows platform 2022-01-11 15:41:20 +01:00
bigjimlefou 408b982eb3 Use of platform-specific specific file separator 2022-01-11 15:41:19 +01:00
bigjimlefou dd7e7711a8 Use of platform-specific specific file separator 2022-01-11 15:41:19 +01:00
bigjimlefou 5a3f7853a6 Fix failing test on Windows platform. 2022-01-11 15:41:19 +01:00
Roland PramlandFOCONIS\szemenyei 01847e44de Always use UTF-8 2022-01-11 10:11:13 +01:00
FOCONIS\szemenyei 0cf9f0bf58 Revert "at first revert solution"
This reverts commit b01b44af10.
2022-01-11 09:49:02 +01:00
FOCONIS\szemenyei b01b44af10 at first revert solution 2022-01-11 09:48:47 +01:00
FOCONIS\szemenyei 8d85000970 Fix Checksum calculate() with special characters
(cherry picked from commit e9efd5a702)
2022-01-11 09:47:44 +01:00
Jonas Pöhler e7f9c63502 Clear up some possible confusion in the test 2022-01-05 15:46:34 +01:00
Jonas Pöhler eb21b41fba Refactor and fixes for interfaces (like Path) + extend existing tests 2022-01-05 14:22:24 +01:00
Jonas Pöhler 3dc6c567a0 Merge remote-tracking branch 'ebean/master' into fix-scalartype-problem2 2022-01-05 13:34:29 +01:00
Rob BygraveandGitHub 18eed47306 Merge pull request #2475 from bigjimlefou/fixLocale
Fix locale problem with TestCsvReader and TestCsvReaderWithCallback.
2021-12-24 11:10:05 +13:00
Cédric Sougné 9ddf1333ed Fix locale problem with TestCsvReader and TestCsvReaderWithCallback. 2021-12-23 17:19:44 +01:00
Rob Bygrave 73896d375f Bump test modules to 12.14.1-SNAPSHOT after release 2021-12-20 16:49:18 +13:00
Rob Bygrave 3f645211a6 [maven-release-plugin] prepare for next development iteration 2021-12-20 16:34:23 +13:00
Rob Bygrave 451e2fa93c [maven-release-plugin] prepare release ebean-parent-12.14.0 2021-12-20 16:34:17 +13:00
Rob Bygrave 2ff3b0acb7 Update gitflow cron schedule for mariadb, sqlserver, jdk-18 2021-12-20 16:20:08 +13:00
tFellnerandGitHub 42594533da Support for Sequences in MariaDB (#2304)
* Support for Sequneces in MariaDB

* clean up readSequenceValue in test class

* remove flakiness

* remove change for later discussion

* replace deprecated methods

* strictly allow sequences
2021-12-20 16:11:30 +13:00
Rob Bygrave 678494f331 Bump version of logback used in tests only 2021-12-20 16:09:33 +13:00
Rob Bygrave 361df6732a #2472 - BeanPersistController and isCascade() for delete requests (following #2458) 2021-12-20 15:49:58 +13:00
Rob Bygrave c3320f4a0b Bump version to 12.14.0-SNAPSHOT 2021-12-20 13:14:34 +13:00
Rob Bygrave c411d9a665 Bump version to 12.14.0-SNAPSHOT 2021-12-20 12:47:36 +13:00
Rob Bygrave 8ea2c31076 #2471 - Bump avaje-config to 1.7 (from 1.5) with removed jndi lookup for DataSource 2021-12-20 12:45:30 +13:00
Rob Bygrave 254b0df16b #2470 - Bump jedis to version 3.8.0 (from 3.6.3) 2021-12-20 12:40:41 +13:00
Rob Bygrave c0f4451d20 Fix pom versions in test only modules after release 2021-12-20 10:47:26 +13:00
Rob BygraveandGitHub 6c544a2835 Merge pull request #2468 from FOCONIS/pr/fix/jdbc_url_sqlserver_tests
Unify JDBC URL for SqlServer (analog to testconfig-files)
2021-12-20 10:29:58 +13:00
Rob BygraveandGitHub 227d18bbf0 Merge pull request #2469 from FOCONIS/pr/enh/helper_methods_annotation_util
Add metaHas and metaFindAll in AnnotationUtil
2021-12-20 10:28:32 +13:00
Rob BygraveandGitHub 18cdd2ed7a Merge pull request #2466 from FOCONIS/pr/fix/remove_unused_load_error_handler
Remove unused LoadErrorHandler interface
2021-12-20 10:27:14 +13:00
Jonas Pöhler 91d1fb8cea ADD: javadoc 2021-12-17 15:10:30 +01:00
Jonas Pöhler 058021f8d0 ADD: metaHas and metaFindAll as functional sugar 2021-12-17 13:56:08 +01:00
Roland PramlandJonas Pöhler f4d270e8b5 FIX: JDBC URL for SqlServer (similar to testconfig-files) 2021-12-17 13:26:00 +01:00
Jonas Pöhler 7b8052c097 Merge remote-tracking branch 'ebean/master' into pr/fix/remove_unused_load_error_handler 2021-12-17 13:22:46 +01:00
Rob Bygrave 68b7deba9d Put back h2database to 1.4.199 as 2.x breaks way too many things, need to work on that 2021-12-17 23:25:49 +13:00
Roland PramlandJonas Pöhler 65e924feaa Deleted obsolete LoadErrorHandler 2021-12-17 10:44:42 +01:00
Rob Bygrave 6cc5e83b01 Merge branch 'master' of github.com:ebean-orm/ebean 2021-12-17 21:47:17 +13:00
Rob Bygrave 752d5d4782 Remove pom.xml.releaseBackup from barfed release 2021-12-17 21:47:07 +13:00
Rob BygraveandGitHub 20fdbfc972 Merge pull request #2463 from ebean-orm/dependabot/maven/ebean-test/com.h2database-h2-2.0.202
Bump h2 from 1.4.199 to 2.0.202 in /ebean-test
2021-12-17 21:44:21 +13:00
Rob Bygrave bd01dfd29a Bump parent pom, moved to s01.oss.sonatype.org 2021-12-17 20:57:46 +13:00
Rob Bygrave 6a9b5944a3 Remove release.properties that somehow got into git after release 2021-12-17 20:55:19 +13:00
dependabot[bot]andGitHub 6e31de6f2e Bump h2 from 1.4.199 to 2.0.202 in /ebean-test
Bumps [h2](https://github.com/h2database/h2database) from 1.4.199 to 2.0.202.
- [Release notes](https://github.com/h2database/h2database/releases)
- [Commits](https://github.com/h2database/h2database/compare/version-1.4.199...version-2.0.202)

---
updated-dependencies:
- dependency-name: com.h2database:h2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-17 04:33:53 +00:00
Rob Bygrave 5fddc37037 [maven-release-plugin] prepare for next development iteration 2021-12-17 17:26:43 +13:00
Roland Praml f830662cce Improve TypeManager - cache typeNotFound information. 2021-12-02 11:18:22 +01:00
Roland Praml 84ac737ceb ADD: Testcase for Calendar 2021-12-02 10:42:49 +01:00
Roland Praml 483f0398b2 Fix: 'No ScalarType registered for class java.util.GregorianCalendar' - check all registered scalar type if no exact match was found 2021-12-02 08:30:24 +01:00
115 changed files with 1119 additions and 2345 deletions
+2 -2
View File
@@ -3,8 +3,8 @@ name: JDK 18-ea
on:
workflow_dispatch:
# schedule:
# - cron: '30 6 * * *'
schedule:
- cron: '30 6 * * 1,3,5'
jobs:
build:
+4 -1
View File
@@ -1,7 +1,10 @@
name: MariaDB 10.6
on: [workflow_dispatch]
on:
workflow_dispatch:
schedule:
- cron: '10 7 * * 1,4'
jobs:
build:
+4 -1
View File
@@ -1,7 +1,10 @@
name: SqlServer 2017 latest
on: [workflow_dispatch]
on:
workflow_dispatch:
schedule:
- cron: '10 7 * * 2,5'
jobs:
build:
+2 -2
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2</version>
<version>12.14.1</version>
</parent>
<name>ebean api</name>
@@ -27,7 +27,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-config</artifactId>
<version>1.5</version>
<version>1.7</version>
</dependency>
<!--
-130
View File
@@ -1,130 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2-SNAPSHOT</version>
</parent>
<name>ebean api</name>
<description>ebean api</description>
<artifactId>ebean-api</artifactId>
<dependencies>
<!--
Projects are expected to explicit depend on version
of slf4j that they want to use
-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-config</artifactId>
<version>1.5</version>
</dependency>
<!--
Class retention Nonnull and Nullable annotations
to assist with IDE auto-completion with Ebean API
-->
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-lang</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>persistence-api</artifactId>
<version>2.2.5</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-annotation</artifactId>
<version>7.3</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-types</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource-api</artifactId>
<version>${ebean-datasource.version}</version>
</dependency>
<!-- Jackson core used internally by Ebean -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
<!-- provided scope for JsonNode support -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
<!-- Provided scope so that the H2HistoryTrigger can live in Ebean core
and not require a separate module for it -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.199</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.24</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>io.avaje.tile:moditech-module:1.0</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -7,13 +7,10 @@ public class BasicSqlAnsiLimiter implements BasicSqlLimiter {
@Override
public String limit(String dbSql, int firstRow, int maxRows) {
StringBuilder sb = new StringBuilder(50 + dbSql.length());
sb.append(dbSql);
if (firstRow > 0) {
sb.append(" ").append("offset");
sb.append(" ").append(firstRow).append(" rows");
sb.append(" offset ").append(firstRow).append(" rows");
}
if (maxRows > 0) {
sb.append(" fetch next ").append(maxRows).append(" rows only");
@@ -1,6 +1,10 @@
package io.ebean.config.dbplatform.mariadb;
import javax.sql.DataSource;
import io.ebean.BackgroundExecutor;
import io.ebean.annotation.Platform;
import io.ebean.config.dbplatform.PlatformIdGenerator;
import io.ebean.config.dbplatform.mysql.BaseMySqlPlatform;
/**
@@ -11,6 +15,14 @@ public class MariaDbPlatform extends BaseMySqlPlatform {
public MariaDbPlatform() {
super();
this.platform = Platform.MARIADB;
this.sequenceBatchMode = false;
this.historySupport = new MariaDbHistorySupport();
this.dbIdentity.setSupportsSequence(true);
}
@Override
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int stepSize, String seqName) {
return new MariaDbSequence(be, ds, seqName, stepSize);
}
}
@@ -0,0 +1,24 @@
package io.ebean.config.dbplatform.mariadb;
import io.ebean.BackgroundExecutor;
import io.ebean.config.dbplatform.SequenceStepIdGenerator;
import javax.sql.DataSource;
public class MariaDbSequence extends SequenceStepIdGenerator {
private final String nextSql;
/**
* Construct where batchSize is the sequence step size.
*/
public MariaDbSequence(BackgroundExecutor be, DataSource ds, String seqName, int stepSize) {
super(be, ds, seqName, stepSize);
this.nextSql = "select next value for " + seqName;
}
@Override
public String getSql(int batchSize) {
return nextSql;
}
}
@@ -11,6 +11,7 @@ public class Oracle11Platform extends OraclePlatform {
public Oracle11Platform() {
super();
this.platform = Platform.ORACLE11;
this.columnAliasPrefix = "c";
this.sqlLimiter = new OracleRownumSqlLimiter();
this.basicSqlLimiter = new OracleRownumBasicLimiter();
dbIdentity.setIdType(IdType.SEQUENCE);
@@ -0,0 +1,13 @@
package io.ebean.config.dbplatform.oracle;
/**
* Oracle 12 platform using column alias.
*/
public class Oracle12Platform extends OraclePlatform {
public Oracle12Platform() {
super();
//this.platform = Platform.ORACLE12;
this.columnAliasPrefix = "c";
}
}
@@ -22,7 +22,6 @@ public class OraclePlatform extends DatabasePlatform {
public OraclePlatform() {
super();
this.platform = Platform.ORACLE;
this.columnAliasPrefix = "c";
this.supportsDeleteTableAlias = true;
this.maxTableNameLength = 30;
this.maxConstraintNameLength = 30;
@@ -35,11 +34,9 @@ public class OraclePlatform extends DatabasePlatform {
dbIdentity.setSupportsSequence(true);
dbIdentity.setSupportsIdentity(true);
dbIdentity.setSupportsGetGeneratedKeys(true);
this.dbDefaultValue.setFalse("0");
this.dbDefaultValue.setTrue("1");
this.dbDefaultValue.setNow("current_timestamp");
this.treatEmptyStringsAsNull = true;
this.likeClauseRaw = "like ?";
@@ -56,7 +53,6 @@ public class OraclePlatform extends DatabasePlatform {
booleanDbType = Types.INTEGER;
dbTypeMap.put(DbType.BOOLEAN, new DbPlatformType("number(1)"));
dbTypeMap.put(DbType.INTEGER, new DbPlatformType("number", 10));
dbTypeMap.put(DbType.BIGINT, new DbPlatformType("number", 19));
dbTypeMap.put(DbType.REAL, new DbPlatformType("number", 19, 4));
@@ -65,12 +61,10 @@ public class OraclePlatform extends DatabasePlatform {
dbTypeMap.put(DbType.TINYINT, new DbPlatformType("number", 3));
dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("number", 16, 3));
dbTypeMap.put(DbType.VARCHAR, new DbPlatformType("varchar2", 255));
dbTypeMap.put(DbType.LONGVARBINARY, new DbPlatformType("blob"));
dbTypeMap.put(DbType.LONGVARCHAR, new DbPlatformType("clob"));
dbTypeMap.put(DbType.VARBINARY, new DbPlatformType("raw", 255));
dbTypeMap.put(DbType.BINARY, new DbPlatformType("raw", 255));
dbTypeMap.put(DbType.TIME, new DbPlatformType("timestamp"));
}
@@ -1,14 +0,0 @@
package io.ebean.plugin;
import io.ebean.bean.EntityBean;
/**
* Errorhandler to handle load errors and may be recover correct value.
*
* @author Roland Praml, FOCONIS AG
*
*/
@FunctionalInterface
public interface LoadErrorHandler {
void handleLoadError(EntityBean bean, Property prop, String fullName, Exception e);
}
@@ -18,7 +18,7 @@ import java.util.Locale;
* try {
* File f = new File("src/test/resources/test1.csv");
*
* FileReader reader = new FileReader(f);
* FileReader reader = new FileReader(f, encoding);
*
* CsvReader<Customer> csvReader = DB.createCsvReader(Customer.class);
*
@@ -71,6 +71,20 @@ public class AnnotationUtil {
return typeGet(clazz, annotation) != null;
}
/**
* Check if an element is annotated with an annotation of given type searching meta-annotations.
*/
public static boolean metaHas(AnnotatedElement element, Class<?> annotationType) {
return !metaFindAll(element, annotationType).isEmpty();
}
/**
* Find all the annotations of a given type searching meta-annotations.
*/
public static Set<Annotation> metaFindAll(AnnotatedElement element, Class<?> annotationType) {
return metaFindAllFor(element, Collections.singleton(annotationType));
}
/**
* Find all the annotations for the filter searching meta-annotations.
*/
@@ -0,0 +1,48 @@
package io.ebean.util;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
/**
* Utilities for IO. It uses UTF-8 as encoding when reading/writing and uses
* buffered IO for better performance.
*/
public class IOUtils {
/**
* Read from stream as UTF-8.
*/
public static BufferedReader newReader(InputStream is) {
return new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
}
/**
* Read from file as UTF-8.
*/
public static BufferedReader newReader(File file) throws FileNotFoundException {
return newReader(new FileInputStream(file));
}
/**
* Write to stream as UTF-8
*/
public static BufferedWriter newWriter(OutputStream os) {
return new BufferedWriter(new OutputStreamWriter(os, StandardCharsets.UTF_8));
}
/**
* Write to file as UTF-8
*/
public static BufferedWriter newWriter(File file) throws FileNotFoundException {
return newWriter(new FileOutputStream(file));
}
}
+3 -3
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2</version>
<version>12.14.1</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.13.2</tag>
<tag>ebean-parent-12.14.1</tag>
</scm>
<name>ebean autotune</name>
@@ -26,7 +26,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
-74
View File
@@ -1,74 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2-SNAPSHOT</version>
</parent>
<!-- <parent>-->
<!-- <groupId>org.avaje</groupId>-->
<!-- <artifactId>java8-oss</artifactId>-->
<!-- <version>2.2</version>-->
<!-- </parent>-->
<scm>
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
<tag>HEAD</tag>
</scm>
<name>ebean autotune</name>
<description>ebean automatic query tuning module</description>
<artifactId>ebean-autotune</artifactId>
<dependencies>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- needed for java 11+ -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource</artifactId>
<version>${ebean-datasource.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.24</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>io.ebean.tile:enhancement:12.11.3</tile>
<tile>io.avaje.tile:moditech-module:1.0</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
+15 -15
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2</version>
<version>12.14.1</version>
</parent>
<name>ebean bom</name>
@@ -71,88 +71,88 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-xml</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-autotune</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>kotlin-querybean-generator</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-postgis</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-redis</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
</dependency>
</dependencies>
-162
View File
@@ -1,162 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2-SNAPSHOT</version>
</parent>
<name>ebean bom</name>
<description>ebean bill of materials pom</description>
<artifactId>ebean-bom</artifactId>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<!-- dependencies external to this ebean.git build -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-runner</artifactId>
<version>${ebean-ddl-runner.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-migration-auto</artifactId>
<version>${ebean-migration-auto.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-migration</artifactId>
<version>${ebean-migration.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource-api</artifactId>
<version>${ebean-datasource.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource</artifactId>
<version>${ebean-datasource.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-agent</artifactId>
<version>${ebean-agent.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-maven-plugin</artifactId>
<version>${ebean-maven-plugin.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test-docker</artifactId>
<version>${ebean-test-docker.version}</version>
</dependency>
<!-- modules -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean</artifactId>
<version>12.13.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>12.13.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>12.13.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>12.13.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>12.13.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-xml</artifactId>
<version>12.13.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-autotune</artifactId>
<version>12.13.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>12.13.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>kotlin-querybean-generator</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-postgis</artifactId>
<version>12.13.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-redis</artifactId>
<version>12.13.2-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
+2 -2
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2</version>
<version>12.14.1</version>
</parent>
<artifactId>ebean-core-type</artifactId>
@@ -16,7 +16,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
</dependency>
<dependency>
-46
View File
@@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2-SNAPSHOT</version>
</parent>
<artifactId>ebean-core-type</artifactId>
<name>ebean core type</name>
<description>ebean scalar types api</description>
<dependencies>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>12.13.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.24</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>io.avaje.tile:moditech-module:1.0</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
+5 -5
View File
@@ -3,7 +3,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2</version>
<version>12.14.1</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.13.2</tag>
<tag>ebean-parent-12.14.1</tag>
</scm>
<dependencies>
@@ -41,19 +41,19 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
</dependency>
<dependency>
-247
View File
@@ -1,247 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2-SNAPSHOT</version>
</parent>
<artifactId>ebean-core</artifactId>
<packaging>jar</packaging>
<name>ebean core</name>
<description>ebean core module</description>
<url>https://ebean.io/</url>
<scm>
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
<tag>HEAD</tag>
</scm>
<dependencies>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-runner</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>classpath-scanner</artifactId>
<version>6.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-migration-auto</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>12.13.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>12.13.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>12.13.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.8-1</version>
</dependency>
<!--
Class retention Nonnull and Nullable annotations
to assist with IDE auto-completion with Ebean API
-->
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsr305-x</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
<!-- Provided scope so that the H2HistoryTrigger can live in Ebean core
and not require a separate module for it -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.199</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
<version>1.3</version>
<optional>true</optional>
</dependency>
<!-- validation annotations Size etc -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>3.0.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.7</version>
<optional>true</optional>
</dependency>
<!-- <dependency>-->
<!-- <groupId>javax.annotation</groupId>-->
<!-- <artifactId>javax.annotation-api</artifactId>-->
<!-- <version>1.3.2</version>-->
<!-- <optional>true</optional>-->
<!-- </dependency>-->
<!-- Jackson core used internally by Ebean -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
<!-- Provided scope for Postgres JSON/JSONB support -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.24</version>
<optional>true</optional>
</dependency>
<!-- Test scope -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource</artifactId>
<version>${ebean-datasource.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.ebean</groupId>
<artifactId>ebean-maven-plugin</artifactId>
<version>${ebean-maven-plugin.version}</version>
<executions>
<execution>
<id>test</id>
<phase>process-test-classes</phase>
<configuration>
<transformArgs>debug=0</transformArgs>
</configuration>
<goals>
<goal>testEnhance</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<trimStackTrace>false</trimStackTrace>
<failIfNoTests>false</failIfNoTests>
<includes>
<include>**/Test*.java</include>
<include>**/*Test.java</include>
<include>**/*Tests.java</include>
</includes>
<systemProperties>
<property>
<!-- transfer datasource.default parameter -->
<name>datasource.default</name>
<value>${datasource.default}</value>
</property>
<property>
<!-- transfer dbClockDelta parameter -->
<name>dbClockDelta</name>
<value>${dbClockDelta}</value>
</property>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<doctitle>Ebean 12</doctitle>
<overview>src/main/java/io/ebean/overview.html</overview>
<excludePackageNames>io.ebeaninternal.*:io.ebeanservice:io.ebean.common:io.ebean.bean:io.ebean.service:io.ebean.metric:io.ebean.util:io.ebean.config.properties:io.ebean.config.dbplatform</excludePackageNames>
<linksource>true</linksource>
<overview>src/main/java/com/avaje/ebean/overview.html</overview>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.24</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>io.avaje.tile:moditech-module:1.0</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -3,13 +3,13 @@ package io.ebeaninternal.server.core;
import io.ebean.ScriptRunner;
import io.ebean.ddlrunner.DdlRunner;
import io.ebean.ddlrunner.ScriptTransform;
import io.ebean.util.IOUtils;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.util.UrlHelper;
import javax.persistence.PersistenceException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.Reader;
import java.net.URL;
@@ -66,8 +66,9 @@ final class DScriptRunner implements ScriptRunner {
throw new IllegalArgumentException("resource is null?");
}
try (InputStream inputStream = UrlHelper.openNoCache(resource)) {
return readContent(new InputStreamReader(inputStream));
try (InputStream inputStream = UrlHelper.openNoCache(resource);
Reader reader = IOUtils.newReader(inputStream)) {
return readContent(reader);
} catch (IOException e) {
throw new PersistenceException("Failed to read script content", e);
@@ -13,6 +13,7 @@ import io.ebean.config.dbplatform.mysql.MySql55Platform;
import io.ebean.config.dbplatform.mysql.MySqlPlatform;
import io.ebean.config.dbplatform.nuodb.NuoDbPlatform;
import io.ebean.config.dbplatform.oracle.Oracle11Platform;
import io.ebean.config.dbplatform.oracle.Oracle12Platform;
import io.ebean.config.dbplatform.oracle.OraclePlatform;
import io.ebean.config.dbplatform.postgres.Postgres9Platform;
import io.ebean.config.dbplatform.postgres.PostgresPlatform;
@@ -25,11 +26,7 @@ import io.ebeaninternal.api.DbOffline;
import javax.persistence.PersistenceException;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.*;
/**
* Create a DatabasePlatform from the configuration.
@@ -87,6 +84,9 @@ public class DatabasePlatformFactory {
if (dbName.equals("oracle11") || dbName.equals("oracle10") || dbName.equals("oracle9")) {
return new Oracle11Platform();
}
if (dbName.equals("oracle12")) {
return new Oracle12Platform();
}
if (dbName.equals("oracle")) {
return new OraclePlatform();
}
@@ -173,7 +173,13 @@ public class DatabasePlatformFactory {
}
private DatabasePlatform oracleVersion(int majorVersion) {
return majorVersion < 12 ? new Oracle11Platform() : new OraclePlatform();
if (majorVersion < 12) {
return new Oracle11Platform();
}
if (majorVersion < 13) {
return new Oracle12Platform();
}
return new OraclePlatform();
}
private DatabasePlatform mysqlVersion(int majorVersion, int minorVersion) {
@@ -226,7 +226,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
*/
@Override
public void addBeanToCollectionWithCreate(EntityBean parentBean, EntityBean detailBean, boolean withCheck) {
BeanCollection<?> bc = (BeanCollection<?>) super.getValue(parentBean);
BeanCollection<?> bc = beanCollection(parentBean);
if (bc == null) {
bc = help.createEmpty(parentBean);
setValue(parentBean, bc);
@@ -234,6 +234,15 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
help.add(bc, detailBean, withCheck);
}
private BeanCollection<?> beanCollection(EntityBean parentBean) {
try {
return (BeanCollection<?>) super.getValue(parentBean);
} catch (ClassCastException e) {
// fetching element collection, ok for now
return null;
}
}
/**
* Return true if this is considered 'empty' from a save perspective.
*/
@@ -10,23 +10,18 @@ public final class DbExpressionHandlerFactory {
* Create and return the appropriate platform specific handing of expressions.
*/
public static DbExpressionHandler from(DatabasePlatform databasePlatform) {
Platform platform = databasePlatform.getPlatform();
Platform platform = databasePlatform.getPlatform().base();
switch (platform) {
case H2:
return new H2DbExpression();
case POSTGRES:
case POSTGRES9:
return new PostgresDbExpression();
case MARIADB:
return new MariaDbExpression();
case MYSQL55:
case MYSQL:
return new MySqlDbExpression();
case ORACLE:
case ORACLE11:
return new OracleDbExpression();
case SQLSERVER16:
case SQLSERVER17:
case SQLSERVER:
return new SqlServerDbExpression();
case HANA:
@@ -333,6 +333,13 @@ public final class DefaultPersister implements Persister {
* Recursively delete the bean. This calls back to the EbeanServer.
*/
private int deleteRecurse(EntityBean detailBean, Transaction t, DeleteMode deleteMode) {
return deleteRequest(createDeleteCascade(detailBean, t, deleteMode.persistType()));
}
/**
* Delete without being a cascade.
*/
private int delete(EntityBean detailBean, Transaction t, DeleteMode deleteMode) {
return deleteRequest(createDeleteRequest(detailBean, t, deleteMode.persistType()));
}
@@ -560,7 +567,7 @@ public final class DefaultPersister implements Persister {
}
}
private void deleteList(List<?> beanList, SpiTransaction t, DeleteMode deleteMode, boolean children) {
private void deleteCascade(List<?> beanList, SpiTransaction t, DeleteMode deleteMode, boolean children) {
if (children) {
t.depth(-1);
t.checkBatchEscalationOnCollection();
@@ -604,7 +611,7 @@ public final class DefaultPersister implements Persister {
for (Object id : ids) {
EntityBean bean = descriptor.createEntityBean();
descriptor.convertSetId(id, bean);
int rowCount = deleteRecurse(bean, transaction, deleteMode);
int rowCount = delete(bean, transaction, deleteMode);
if (rowCount == -1) {
total = -1;
} else if (total != -1) {
@@ -656,7 +663,7 @@ public final class DefaultPersister implements Persister {
t.logSummary("-- DeleteById of " + descriptor.name() + " ids[" + idList + "] requires fetch of foreign key values");
}
List<?> beanList = server.findList(q, t);
deleteList(beanList, t, deleteMode, false);
deleteCascade(beanList, t, deleteMode, false);
return beanList.size();
} else {
@@ -994,6 +1001,8 @@ public final class DefaultPersister implements Persister {
executeSqlUpdate(sqlDelete, t);
} else {
// TODO: Review first checking if many property is loaded and using the loaded beans
// ... and only using findIdsByParentId() when the many property isn't loaded
// Delete recurse using the Id values of the children
Object parentId = desc.getId(parentBean);
List<Object> idsByParentId = many.findIdsByParentId(parentId, null, t, excludeDetailIds, deleteMode.isHard());
@@ -1017,7 +1026,7 @@ public final class DefaultPersister implements Persister {
for (Object id : childIds) {
refList.add(targetDesc.createReference(id, null));
}
deleteList(refList, t, deleteMode, true);
deleteCascade(refList, t, deleteMode, true);
} else {
// perform delete by statement if possible
delete(targetDesc, null, childIds, t, deleteMode);
@@ -1157,6 +1166,10 @@ public final class DefaultPersister implements Persister {
return createDeleteRequest(bean, t, type, Flags.ZERO);
}
private <T> PersistRequestBean<T> createDeleteCascade(EntityBean bean, Transaction t, Type type) {
return createDeleteRequest(bean, t, type, Flags.RECURSE);
}
@SuppressWarnings({"unchecked"})
private <T> PersistRequestBean<T> createDeleteRequest(Object bean, Transaction t, PersistRequest.Type type, int flags) {
BeanManager<T> mgr = beanManager(bean.getClass());
@@ -1167,7 +1180,7 @@ public final class DefaultPersister implements Persister {
type = Type.DELETE_SOFT;
}
PersistRequestBean<T> request = new PersistRequestBean<>(server, (T)bean, null, mgr, (SpiTransaction) t, persistExecute, type, flags);
PersistRequestBean<T> request = new PersistRequestBean<>(server, (T) bean, null, mgr, (SpiTransaction) t, persistExecute, type, flags);
request.initForSoftDelete();
return request;
}
@@ -1186,7 +1199,7 @@ public final class DefaultPersister implements Persister {
*/
@SuppressWarnings("unchecked")
private <T> BeanManager<T> beanManager(Class<?> cls) {
BeanManager<T> mgr = (BeanManager<T>)beanDescriptorManager.beanManager(cls);
BeanManager<T> mgr = (BeanManager<T>) beanDescriptorManager.beanManager(cls);
if (mgr == null) {
throw new PersistenceException(errNotRegistered(cls));
}
@@ -13,11 +13,8 @@ import io.ebeaninternal.server.persist.dmlbind.BindableList;
import java.sql.SQLException;
import static io.ebean.annotation.Platform.MARIADB;
import static io.ebean.annotation.Platform.MYSQL;
/**
* Meta data for insert handler. The meta data is for a particular bean type. It
* Metadata for insert handler. The metadata is for a particular bean type. It
* is considered immutable and is thread safe.
*/
final class InsertMeta {
@@ -153,31 +150,25 @@ final class InsertMeta {
private String genSql(boolean nullId, String table, boolean draftTable) {
GenerateDmlRequest request = new GenerateDmlRequest();
request.setInsertSetMode();
request.append("insert into ").append(table);
if (nullId && noColumnsForInsert(draftTable)) {
return request.append(defaultValues()).toString();
}
request.append(" (");
if (!nullId) {
id.dmlAppend(request);
}
if (shadowFKey != null) {
shadowFKey.dmlAppend(request);
}
if (discriminator != null) {
discriminator.dmlAppend(request);
}
if (draftTable) {
all.dmlAppend(request);
} else {
allExcludeDraftOnly.dmlAppend(request);
}
request.append(") values (");
request.append(request.getInsertBindBuffer());
request.append(")");
@@ -185,7 +176,14 @@ final class InsertMeta {
}
private String defaultValues() {
return platform.base() == MYSQL || platform.base() == MARIADB ? " values (default)" : " default values";
switch (platform.base()) {
case MYSQL:
case MARIADB:
case ORACLE:
return " values (default)";
default:
return " default values";
}
}
/**
@@ -4,11 +4,13 @@ import io.ebean.ProfileLocation;
import io.ebean.config.ProfilingConfig;
import io.ebean.plugin.Plugin;
import io.ebean.plugin.SpiServer;
import io.ebean.util.IOUtils;
import io.ebeaninternal.api.CoreLog;
import io.ebeaninternal.api.SpiProfileHandler;
import org.slf4j.Logger;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
@@ -123,7 +125,7 @@ public final class DefaultProfileHandler implements SpiProfileHandler, Plugin {
try {
String now = DTF.format(LocalDateTime.now());
File file = new File(dir, "txprofile-" + now + ".tprofile");
out = new BufferedWriter(new FileWriter(file));
out = IOUtils.newWriter(file);
} catch (IOException e) {
log.error("Not expected", e);
}
@@ -193,7 +193,7 @@ public final class DefaultTypeManager implements TypeManager {
List<? extends ScalarType<?>> types = plugin.createTypes(config, objectMapper);
for (ScalarType<?> type : types) {
log.debug("adding ScalarType {}", type.getClass());
addCustomType(type);
add(type);
}
}
}
@@ -211,25 +211,6 @@ public final class DefaultTypeManager implements TypeManager {
logAdd(scalarType);
}
/**
* Register the ScalarType for an enum. This is special in the sense that an Enum
* can have many classes if it uses method overrides and we need to register all
* the variations/classes for the enum.
*/
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void addEnumType(ScalarType<?> scalarType, Class<? extends Enum> enumClass) {
Set<Class<?>> mappedClasses = new HashSet<>();
mappedClasses.add(enumClass);
for (Object value : EnumSet.allOf(enumClass).toArray()) {
mappedClasses.add(value.getClass());
}
for (Class<?> cls : mappedClasses) {
typeMap.put(cls, scalarType);
}
logAdd(scalarType);
}
private void logAdd(ScalarType<?> scalarType) {
if (log.isTraceEnabled()) {
String msg = "ScalarType register [" + scalarType.getClass().getName() + "]";
@@ -275,16 +256,43 @@ public final class DefaultTypeManager implements TypeManager {
"ScalarType of Joda LocalTime not defined. You need to set DatabaseConfig.jodaLocalTimeMode to"
+ " either 'normal' or 'utc'. UTC is the old mode using UTC timezone but local time zone is now preferred as 'normal' mode.");
}
found = checkInterfaceTypes(type);
found = checkInheritedTypes(type);
}
return found;
return found != ScalarTypeNotFound.INSTANCE ? found : null; // Do not return ScalarTypeNotFound, otherwise checks will fail
}
private ScalarType<?> checkInterfaceTypes(Class<?> type) {
if (java.nio.file.Path.class.isAssignableFrom(type)) {
return typeMap.get(java.nio.file.Path.class);
/**
* Checks the typeMap for inherited types.
*
* If e.g. <code>type</code> is a <code>GregorianCalendar</code>, then this method
* will check the class hierarchy and will probably return a
* <code>ScalarTypeCalendar</code> To speed up a second lookup, it will write
* back the found scalarType to typeMap.
*
* @param type the for which to search for a <code>ScalarType</code>
* @return either a valid <code>ScalarType</code> if one could be found or {@link ScalarTypeNotFound#INSTANCE} if not
*/
private ScalarType<?> checkInheritedTypes(Class<?> type) {
// first step loop through inheritance chain
Class<?> parent = type;
while (parent != null && parent != Object.class) {
ScalarType<?> found = typeMap.get(parent);
if (found != null && found != ScalarTypeNotFound.INSTANCE) {
typeMap.put(type, found); // store type for next lookup
return found;
}
// second step - loop through interfaces of this type
for (Class<?> iface: parent.getInterfaces()) {
found = checkInheritedTypes(iface);
if (found != null && found != ScalarTypeNotFound.INSTANCE) {
typeMap.put(type, found); // store type for next lookup
return found;
}
}
parent = parent.getSuperclass();
}
return null;
typeMap.put(type, ScalarTypeNotFound.INSTANCE);
return ScalarTypeNotFound.INSTANCE; // no success
}
@Override
@@ -389,7 +397,7 @@ public final class DefaultTypeManager implements TypeManager {
private DocPropertyType getDocType(Type genericType) {
if (genericType instanceof Class<?>) {
ScalarType<?> found = typeMap.get(genericType);
ScalarType<?> found = getScalarType((Class<?>)genericType);
if (found != null) {
return found.getDocType();
}
@@ -447,7 +455,7 @@ public final class DefaultTypeManager implements TypeManager {
return scalarType;
}
scalarType = typeMap.get(type);
scalarType = getScalarType(type);
if (scalarType != null) {
if (jdbcType == 0 || scalarType.getJdbcType() == jdbcType) {
// matching type
@@ -565,7 +573,7 @@ public final class DefaultTypeManager implements TypeManager {
// use JPA normal Enum type (without mapping)
scalarEnum = createEnumScalarTypePerSpec(enumType, type);
}
addEnumType(scalarEnum, enumType);
add(scalarEnum);
return scalarEnum;
}
@@ -655,16 +663,13 @@ public final class DefaultTypeManager implements TypeManager {
scalarType = cls.getDeclaredConstructor().newInstance();
}
}
addCustomType(scalarType);
add(scalarType);
} catch (Exception e) {
log.error("Error loading ScalarType [" + cls.getName() + "]", e);
}
}
}
private void addCustomType(ScalarType<?> scalarType) {
add(scalarType);
}
private Object initObjectMapper(DatabaseConfig config) {
Object objectMapper = config.getObjectMapper();
@@ -8,6 +8,7 @@ import io.ebean.core.type.DataReader;
import io.ebean.core.type.DocPropertyType;
import io.ebean.text.TextException;
import io.ebean.text.json.EJson;
import io.ebean.util.IOUtils;
import java.io.*;
import java.nio.charset.StandardCharsets;
@@ -75,14 +76,14 @@ abstract class ScalarTypeJsonMap extends ScalarTypeBase<Map> {
try {
if (keepSource) {
StringWriter jsonBuffer = new StringWriter();
try (InputStreamReader streamReader = new InputStreamReader(is, StandardCharsets.UTF_8)) {
try (Reader streamReader = IOUtils.newReader(is)) {
transferTo(streamReader, jsonBuffer);
}
String rawJson = jsonBuffer.toString();
reader.pushJson(rawJson);
return parse(rawJson);
} else {
try (InputStreamReader streamReader = new InputStreamReader(is, StandardCharsets.UTF_8)) {
try (Reader streamReader = IOUtils.newReader(is)) {
return parse(streamReader);
}
}
@@ -8,12 +8,12 @@ import io.ebean.core.type.DataBinder;
import io.ebean.core.type.DataReader;
import io.ebean.core.type.DocPropertyType;
import io.ebean.text.TextException;
import io.ebean.util.IOUtils;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.sql.SQLException;
@@ -68,7 +68,7 @@ abstract class ScalarTypeJsonNode extends ScalarTypeBase<JsonNode> {
if (is == null) {
return null;
}
try (InputStreamReader reader = new InputStreamReader(is)) {
try (Reader reader = IOUtils.newReader(is)) {
return parse(reader);
} catch (IOException e) {
throw new SQLException("Error reading Blob stream from DB", e);
@@ -0,0 +1,140 @@
package io.ebeaninternal.server.type;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.sql.SQLException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import io.ebean.core.type.DataBinder;
import io.ebean.core.type.DataReader;
import io.ebean.core.type.DocPropertyType;
import io.ebean.core.type.ScalarType;
/**
* Class is required as "null" key in ConcurrentHashMap.
* @author Roland Praml, FOCONIS AG
*
*/
class ScalarTypeNotFound implements ScalarType<Void> {
public static final ScalarTypeNotFound INSTANCE = new ScalarTypeNotFound();
private ScalarTypeNotFound() { }
@Override
public boolean isBinaryType() {
throw new UnsupportedOperationException();
}
@Override
public boolean isMutable() {
throw new UnsupportedOperationException();
}
@Override
public boolean isDirty(Object value) {
throw new UnsupportedOperationException();
}
@Override
public int getLength() {
throw new UnsupportedOperationException();
}
@Override
public boolean isJdbcNative() {
throw new UnsupportedOperationException();
}
@Override
public int getJdbcType() {
throw new UnsupportedOperationException();
}
@Override
public Class<Void> getType() {
throw new UnsupportedOperationException();
}
@Override
public Void read(DataReader reader) throws SQLException {
throw new UnsupportedOperationException();
}
@Override
public void loadIgnore(DataReader reader) {
throw new UnsupportedOperationException();
}
@Override
public void bind(DataBinder binder, Void value) throws SQLException {
throw new UnsupportedOperationException();
}
@Override
public Object toJdbcType(Object value) {
throw new UnsupportedOperationException();
}
@Override
public Void toBeanType(Object value) {
throw new UnsupportedOperationException();
}
@Override
public String formatValue(Void value) {
throw new UnsupportedOperationException();
}
@Override
public String format(Object value) {
throw new UnsupportedOperationException();
}
@Override
public Void parse(String value) {
throw new UnsupportedOperationException();
}
@Override
public DocPropertyType getDocType() {
throw new UnsupportedOperationException();
}
@Override
public boolean isDateTimeCapable() {
throw new UnsupportedOperationException();
}
@Override
public long asVersion(Void value) {
throw new UnsupportedOperationException();
}
@Override
public Void convertFromMillis(long dateTime) {
throw new UnsupportedOperationException();
}
@Override
public Void readData(DataInput dataInput) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public void writeData(DataOutput dataOutput, Void v) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public Void jsonRead(JsonParser parser) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public void jsonWrite(JsonGenerator writer, Void value) throws IOException {
throw new UnsupportedOperationException();
}
}
@@ -32,7 +32,7 @@ public final class SimpleAesEncryptor implements Encryptor {
}
private IvParameterSpec getIvParameterSpec(String initialVector) {
return new IvParameterSpec(initialVector.getBytes());
return new IvParameterSpec(initialVector.getBytes(StandardCharsets.UTF_8));
}
@Override
@@ -17,12 +17,6 @@ public interface TypeManager {
*/
void add(ScalarType<?> scalarType);
/**
* Register a ScalarType for an Enum with can have multiple classes.
*/
@SuppressWarnings("rawtypes")
void addEnumType(ScalarType<?> type, Class<? extends Enum> myEnumClass);
/**
* Return the scalar type for the given logical type.
*/
+4 -4
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2</version>
<version>12.14.1</version>
</parent>
<name>ebean ddl generation</name>
@@ -22,20 +22,20 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-migration</artifactId>
<version>12.12.1</version>
<version>12.13.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
-106
View File
@@ -1,106 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2-SNAPSHOT</version>
</parent>
<name>ebean ddl generation</name>
<description>DDL and DB Migration generation</description>
<artifactId>ebean-ddl-generator</artifactId>
<dependencies>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-runner</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-migration</artifactId>
<version>12.12.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- needed for java 11+ -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
<scope>provided</scope>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource</artifactId>
<version>${ebean-datasource.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.ebean</groupId>
<artifactId>ebean-maven-plugin</artifactId>
<version>${ebean-maven-plugin.version}</version>
<executions>
<execution>
<id>test</id>
<phase>process-test-classes</phase>
<configuration>
<transformArgs>debug=0</transformArgs>
</configuration>
<goals>
<goal>testEnhance</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.24</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>io.avaje.tile:moditech-module:1.0</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -5,6 +5,7 @@ import io.ebean.config.DatabaseConfig;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.ddlrunner.DdlRunner;
import io.ebean.ddlrunner.ScriptTransform;
import io.ebean.util.IOUtils;
import io.ebean.util.JdbcClose;
import io.ebeaninternal.api.SpiDdlGenerator;
import io.ebeaninternal.api.SpiEbeanServer;
@@ -17,13 +18,11 @@ import org.slf4j.LoggerFactory;
import javax.persistence.PersistenceException;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.Reader;
import java.io.Writer;
import java.sql.Connection;
import java.sql.SQLException;
@@ -268,7 +267,7 @@ public class DdlGenerator implements SpiDdlGenerator {
if (is == null) {
log.warn("sql script {} was not found as a resource", sqlScript);
} else {
String content = readContent(new InputStreamReader(is));
String content = readContent(IOUtils.newReader(is)); // 'is' is closed
runScript(connection, false, content, sqlScript);
}
}
@@ -337,7 +336,7 @@ public class DdlGenerator implements SpiDdlGenerator {
protected void writeFile(String fileName, String fileContent) throws IOException {
File f = new File(baseDir, fileName);
try (FileWriter fw = new FileWriter(f)) {
try (Writer fw = IOUtils.newWriter(f)) {
fw.write(fileContent);
fw.flush();
}
@@ -348,7 +347,9 @@ public class DdlGenerator implements SpiDdlGenerator {
if (!f.exists()) {
return null;
}
return readContent(new FileReader(f));
try (Reader reader = IOUtils.newReader(f)) {
return readContent(reader);
}
}
protected String readContent(Reader reader) throws IOException {
@@ -1,8 +1,22 @@
package io.ebeaninternal.dbmigration;
import static io.ebeaninternal.api.PlatformMatch.matchPlatform;
import java.io.File;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.StringJoiner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.ebean.DB;
import io.ebean.Database;
import io.ebean.annotation.Platform;
import io.ebean.config.ClassLoadConfig;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.DbConstraintNaming;
import io.ebean.config.PlatformConfig;
@@ -27,6 +41,8 @@ import io.ebean.config.dbplatform.sqlite.SQLitePlatform;
import io.ebean.config.dbplatform.sqlserver.SqlServer16Platform;
import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform;
import io.ebean.dbmigration.DbMigration;
import io.ebean.util.IOUtils;
import io.ebean.util.StringHelper;
import io.ebeaninternal.api.DbOffline;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.dbmigration.ddlgeneration.DdlOptions;
@@ -42,17 +58,6 @@ import io.ebeaninternal.dbmigration.model.PlatformDdlWriter;
import io.ebeaninternal.extraddl.model.DdlScript;
import io.ebeaninternal.extraddl.model.ExtraDdl;
import io.ebeaninternal.extraddl.model.ExtraDdlXmlReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import static io.ebeaninternal.api.PlatformMatch.matchPlatform;
/**
* Generates DB Migration xml and sql scripts.
@@ -417,7 +422,7 @@ public class DefaultDbMigration implements DbMigration {
String fullName = repeatableMigrationName(script.isInit(), script.getName());
logger.debug("writing repeatable script {}", fullName);
File file = new File(migrationDir, fullName);
try (FileWriter writer = new FileWriter(file)) {
try (Writer writer = IOUtils.newWriter(file)) {
writer.write(script.getValue());
writer.flush();
}
@@ -2,10 +2,11 @@ package io.ebeaninternal.dbmigration;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.migration.MigrationVersion;
import io.ebean.util.IOUtils;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -50,17 +51,17 @@ class IndexMigration {
private void generateIndex() throws IOException {
Collections.sort(all);
FileWriter writer = new FileWriter(indexFile);
for (Entry entry : all) {
writeChecksumPadded(writer, entry.checksum);
writer.write(entry.fileName);
try (Writer writer = IOUtils.newWriter(indexFile)) {
for (Entry entry : all) {
writeChecksumPadded(writer, entry.checksum);
writer.write(entry.fileName);
writer.write(eol);
}
writer.write(eol);
}
writer.write(eol);
writer.close();
}
private void writeChecksumPadded(FileWriter writer, int checksum) throws IOException {
private void writeChecksumPadded(Writer writer, int checksum) throws IOException {
final String asStr = String.valueOf(checksum);
writer.write(asStr);
writer.write(',');
@@ -4,6 +4,8 @@ import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.zip.CRC32;
import io.ebean.util.IOUtils;
/**
* Calculates the checksum for the given file content.
*/
@@ -13,9 +15,8 @@ class MChecksum {
* Returns the checksum of the file. Agnostic of encoding and new line character.
*/
static int calculate(File file) {
try {
try (BufferedReader bufferedReader = IOUtils.newReader(file)) {
final CRC32 crc32 = new CRC32();
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
String line;
while ((line = bufferedReader.readLine()) != null) {
final byte[] lineBytes = line.getBytes(StandardCharsets.UTF_8);
@@ -1,14 +1,15 @@
package io.ebeaninternal.dbmigration.migrationreader;
import io.ebean.util.IOUtils;
import io.ebeaninternal.dbmigration.migration.Migration;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
/**
* Simple writer for output of the Migration/ChangeSet as an XML document.
@@ -26,7 +27,7 @@ public class MigrationXmlWriter {
*/
public void write(Migration migration, File file) {
try (FileWriter writer = new FileWriter(file)) {
try (Writer writer = IOUtils.newWriter(file)) {
writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
if (comment != null) {
@@ -2,6 +2,7 @@ package io.ebeaninternal.dbmigration.model;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.util.IOUtils;
import io.ebeaninternal.dbmigration.ddlgeneration.DdlBuffer;
import io.ebeaninternal.dbmigration.ddlgeneration.DdlHandler;
import io.ebeaninternal.dbmigration.ddlgeneration.DdlWrite;
@@ -14,7 +15,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.List;
@@ -70,16 +70,16 @@ public class PlatformDdlWriter {
*/
protected void writePlatformDdl(DdlWrite write, File resourcePath, String fullVersion) throws IOException {
if (!write.isApplyEmpty()) {
try (FileWriter applyWriter = createWriter(resourcePath, fullVersion, ".sql")) {
try (Writer applyWriter = createWriter(resourcePath, fullVersion, ".sql")) {
writeApplyDdl(applyWriter, write);
applyWriter.flush();
}
}
}
protected FileWriter createWriter(File path, String fullVersion, String suffix) throws IOException {
protected Writer createWriter(File path, String fullVersion, String suffix) throws IOException {
File applyFile = new File(path, fullVersion + suffix);
return new FileWriter(applyFile);
return IOUtils.newWriter(applyFile);
}
/**
@@ -7,7 +7,7 @@ import java.io.File;
import static org.assertj.core.api.Assertions.assertThat;
public class MChecksumTest {
@Test
public void calculate() {
File file = new File("src/test/resources/dbmigration/index/1.0__hello.sql");
@@ -15,4 +15,12 @@ public class MChecksumTest {
assertThat(MChecksum.calculate(file)).isEqualTo(907060870);
}
@Test
public void calculateWithSpecialChars() {
File file = new File("src/test/resources/dbmigration/index-special-chars/1.0__hello.sql");
assertThat(file).exists();
assertThat(MChecksum.calculate(file)).isEqualTo(1859426839);
}
}
@@ -1,5 +1,6 @@
package io.ebeaninternal.dbmigration.ddlgeneration;
import io.ebean.util.IOUtils;
import io.ebeaninternal.dbmigration.migration.AddColumn;
import io.ebeaninternal.dbmigration.migration.ChangeSet;
import io.ebeaninternal.dbmigration.migration.CreateTable;
@@ -9,8 +10,8 @@ import io.ebeaninternal.dbmigration.migrationreader.MigrationXmlReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.Reader;
import java.util.List;
/**
@@ -89,8 +90,7 @@ public class Helper {
public static String asText(InputStream in) throws IOException {
try {
InputStreamReader reader = new InputStreamReader(in);
try (Reader reader = IOUtils.newReader(in)) {
LineNumberReader lineNumberReader = new LineNumberReader(reader);
+1 -1
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2</version>
<version>12.14.1</version>
</parent>
<name>ebean external mapping api</name>
@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2-SNAPSHOT</version>
</parent>
<name>ebean external mapping api</name>
<description>API for mapping external named queries</description>
<artifactId>ebean-externalmapping-api</artifactId>
<build>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.24</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>io.avaje.tile:moditech-module:1.0</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2</version>
<version>12.14.1</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.13.2</tag>
<tag>ebean-parent-12.14.1</tag>
</scm>
<name>ebean external mapping xml</name>
@@ -33,7 +33,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
</dependency>
<dependency>
@@ -59,14 +59,14 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
@@ -1,100 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2-SNAPSHOT</version>
</parent>
<!-- <parent>-->
<!-- <groupId>org.avaje</groupId>-->
<!-- <artifactId>java8-oss</artifactId>-->
<!-- <version>2.2</version>-->
<!-- </parent>-->
<scm>
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
<tag>HEAD</tag>
</scm>
<name>ebean external mapping xml</name>
<description>XML implementation for mapping external named queries</description>
<artifactId>ebean-externalmapping-xml</artifactId>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>12.13.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>classpath-scanner</artifactId>
<version>6.2</version>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource</artifactId>
<version>${ebean-datasource.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.24</version>
<extensions>true</extensions>
<configuration>
<tiles>
<!-- other tiles ... -->
<tile>io.ebean.tile:enhancement:12.11.3</tile>
<tile>io.avaje.tile:moditech-module:1.0</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
+3 -3
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2-SNAPSHOT</version>
<version>12.14.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -29,7 +29,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.2-SNAPSHOT</version>
<version>12.14.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
@@ -51,7 +51,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>12.13.2-SNAPSHOT</version>
<version>12.14.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
+3 -3
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2</version>
<version>12.14.1</version>
</parent>
<name>ebean postgis</name>
@@ -23,7 +23,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
@@ -74,7 +74,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
-118
View File
@@ -1,118 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2-SNAPSHOT</version>
</parent>
<name>ebean postgis</name>
<description>ebean postgis module</description>
<url>https://ebean.io/</url>
<artifactId>ebean-postgis</artifactId>
<properties>
<postgis.jdbc.version>2.2.1</postgis.jdbc.version>
</properties>
<dependencies>
<!-- provided scope -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>net.postgis</groupId>
<artifactId>postgis-jdbc</artifactId>
<version>[${postgis.jdbc.version}]</version>
</dependency>
<!-- expected to be provided -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.24</version>
<scope>provided</scope>
</dependency>
<!-- expected to be provided -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
<scope>provided</scope>
</dependency>
<!-- optionally use geolatte-geom -->
<dependency>
<groupId>org.geolatte</groupId>
<artifactId>geolatte-geom</artifactId>
<version>1.0.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource</artifactId>
<version>${ebean-datasource.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.avaje.composite</groupId>
<artifactId>logback</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- for testing -->
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.24</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>io.ebean.tile:enhancement:12.11.3</tile>
<tile>io.avaje.tile:moditech-module:1.0</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2</version>
<version>12.14.1</version>
</parent>
<name>ebean querybean</name>
@@ -17,7 +17,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
@@ -56,21 +56,21 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
-112
View File
@@ -1,112 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2-SNAPSHOT</version>
</parent>
<name>ebean querybean</name>
<description>Ebean querybean support</description>
<artifactId>ebean-querybean</artifactId>
<dependencies>
<!-- provided scope -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--
Class retention Nonnull and Nullable annotations
to assist with IDE auto-completion with Ebean API
-->
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-lang</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
<optional>true</optional>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource</artifactId>
<version>${ebean-datasource.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.avaje.composite</groupId>
<artifactId>logback</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Enhancement -->
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.24</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>io.ebean.tile:enhancement:12.11.3</tile>
<tile>io.avaje.tile:moditech-module:1.0</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
+7 -7
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2</version>
<version>12.14.1</version>
</parent>
<artifactId>ebean-redis</artifactId>
@@ -16,41 +16,41 @@
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.6.3</version>
<version>3.8.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
-93
View File
@@ -1,93 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2-SNAPSHOT</version>
</parent>
<artifactId>ebean-redis</artifactId>
<name>ebean redis</name>
<description>Ebean Redis L2 Cache</description>
<dependencies>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.avaje.composite</groupId>
<artifactId>logback</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.24</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>io.ebean.tile:enhancement:12.11.3</tile>
<tile>io.avaje.tile:moditech-module:1.0</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
+8 -8
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2</version>
<version>12.14.1</version>
</parent>
<name>ebean test</name>
@@ -29,14 +29,14 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>12.13.2</version>
<version>12.14.1</version>
</dependency>
<dependency>
@@ -56,7 +56,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test-docker</artifactId>
<version>4.3</version>
<version>4.4</version>
</dependency>
<dependency>
@@ -91,7 +91,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-migration</artifactId>
<version>12.12.1</version>
<version>12.13.0</version>
<scope>test</scope>
</dependency>
@@ -187,8 +187,8 @@
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<!-- Note: Using ojdbc10 here will affect loading other drivers on jdk8,
because the driverManager will stop on first load error and stops loading
<!-- Note: Using ojdbc10 here will affect loading other drivers on jdk8,
because the driverManager will stop on first load error and stops loading
other drivers -->
<artifactId>ojdbc8</artifactId>
<version>19.12.0.0</version>
@@ -226,7 +226,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<version>1.2.9</version>
<scope>test</scope>
</dependency>
-261
View File
@@ -1,261 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.2-SNAPSHOT</version>
</parent>
<name>ebean test</name>
<description>Testing support for Ebean</description>
<artifactId>ebean-test</artifactId>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource</artifactId>
<version>${ebean-datasource.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>12.13.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test-docker</artifactId>
<version>4.3</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.14.0</version>
</dependency>
<!-- Including JAXB for DB Migration generation with Java 11+ -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
</dependency>
<!-- Not strictly required but bring in H2 Driver because we use it so much -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.199</version>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsr305</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-migration</artifactId>
<version>12.12.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>mod-uuid</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
<!-- validation annotations Size etc -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.24</version>
<exclusions>
<exclusion>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>9.4.0.jre8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.26</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sap.cloud.db.jdbc</groupId>
<artifactId>ngdbc</artifactId>
<version>2.3.48</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<!-- Note: Using ojdbc10 here will affect loading other drivers on jdk8,
because the driverManager will stop on first load error and stops loading
other drivers -->
<artifactId>ojdbc8</artifactId>
<version>19.12.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>jcc</artifactId>
<version>11.5.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.36.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.nuodb.jdbc</groupId>
<artifactId>nuodb-jdbc</artifactId>
<version>22.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ru.yandex.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.3.1-patch</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.24</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>io.ebean.tile:enhancement:12.11.3</tile>
<tile>io.avaje.tile:moditech-module:1.0</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -11,7 +11,7 @@ class ClickHouseSetup implements PlatformSetup {
config.setDefaultPort(8123);
config.setUsername("default");
config.setPassword("");
config.setUrl("jdbc:clickhouse://localhost:${port}/${databaseName}");
config.setUrl("jdbc:clickhouse://${host}:${port}/${databaseName}");
config.setDriver("ru.yandex.clickhouse.ClickHouseDriver");
config.datasourceDefaults();
@@ -11,7 +11,7 @@ class CockroachSetup implements PlatformSetup {
config.setDefaultPort(26257);
config.setUsername("root");
config.setPassword("");
config.setUrl("jdbc:postgresql://localhost:${port}/${databaseName}?sslmode=disable");
config.setUrl("jdbc:postgresql://${host}:${port}/${databaseName}?sslmode=disable");
config.setDriver("org.postgresql.Driver");
config.datasourceDefaults();
@@ -4,8 +4,8 @@ import io.ebean.config.DatabaseConfig;
import io.ebean.datasource.DataSourceConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.Locale;
import java.util.Properties;
/**
@@ -26,11 +26,9 @@ class Config {
private final String db;
private final String platform;
private String dockerPlatform;
private String databaseName;
private final Properties properties;
private int port;
private String url;
@@ -38,12 +36,10 @@ class Config {
private String schema;
private String username;
private String password;
private final DatabaseConfig config;
private boolean containerDropCreate;
private final Properties dockerProperties = new Properties();
private final DockerHost dockerHost = new DockerHost();
Config(String db, String platform, String databaseName, DatabaseConfig config) {
this.db = db;
@@ -231,11 +227,17 @@ class Config {
void setUrl(String urlPattern) {
String val = getPlatformKey("url", urlPattern);
val = val.replace("${host}", host());
val = val.replace("${port}", String.valueOf(port));
val = val.replace("${databaseName}", databaseName);
this.url = val;
}
String host() {
String explicitDockerHost = getKey("dockerHost", null);
return getKey("host", dockerHost.dockerHost(explicitDockerHost));
}
/**
* Append to the connection URL.
*/
@@ -322,7 +324,6 @@ class Config {
void setDockerVersion(String version) {
String val = getPlatformKey("version", version);
dockerProperties.setProperty(dockerKey("version"), val);
if (containerDropCreate) {
dockerProperties.setProperty(dockerKey("startMode"), "dropCreate");
}
@@ -369,7 +370,10 @@ class Config {
}
private void initDockerProperties() {
if (dockerHost.runningInDocker()) {
// tell ebean-docker-test we are not using localhost (for jdbc DB setup commands)
dockerProperties.setProperty(dockerKey("host"), dockerHost.dockerHost());
}
dockerProperties.setProperty(dockerKey("port"), String.valueOf(port));
dockerProperties.setProperty(dockerKey("dbName"), databaseName);
if (schema != null) {
@@ -11,7 +11,7 @@ class Db2Setup implements PlatformSetup {
config.setDefaultPort(50000);
config.setUsernameDefault();
config.setPasswordDefault();
config.setUrl("jdbc:db2://localhost:${port}/${databaseName}");
config.setUrl("jdbc:db2://${host}:${port}/${databaseName}");
config.setDriver("com.ibm.db2.jcc.DB2Driver");
config.datasourceDefaults();
@@ -0,0 +1,55 @@
package io.ebean.test.config.platform;
import java.io.File;
import java.util.Locale;
/**
* Helper to detect if running inside docker and determine host name for that case.
*/
class DockerHost {
private final boolean runningInDocker;
private String dockerHost;
DockerHost() {
runningInDocker = initInDocker();
}
boolean runningInDocker() {
return runningInDocker;
}
String dockerHost() {
return dockerHost;
}
String dockerHost(String explicitHost) {
if (!runningInDocker) {
return "localhost";
}
dockerHost = explicitHost != null ? explicitHost : defaultDockerHost();
return dockerHost;
}
/**
* Return true if running inside a docker container (we are using docker in docker).
*/
boolean initInDocker() {
return new File("/.dockerenv").exists();
}
/**
* Return the default host name to use when running in docker.
* <p>
* Can instead be explicitly specified via <code>ebean.test.dockerHost</code>.
*/
String defaultDockerHost() {
String os = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH);
if (os.contains("mac") || os.contains("darwin") || os.contains("win")) {
return "host.docker.internal";
} else {
return "172.17.0.1";
}
}
}
@@ -20,7 +20,7 @@ class HanaSetup implements PlatformSetup {
config.setUsername("SYSTEM");
config.setPassword("HXEHana1");
config.setDatabaseName("HXE");
config.setUrl("jdbc:sap://localhost:${port}/?databaseName=${databaseName}");
config.setUrl("jdbc:sap://${host}:${port}/?databaseName=${databaseName}");
String schema = config.getSchema();
if (schema != null && !schema.equals(config.getUsername())) {
config.urlAppend("&currentSchema=" + schema);
@@ -13,7 +13,7 @@ class MariaDBSetup implements PlatformSetup {
config.setDefaultPort(defaultPort);
config.setUsernameDefault();
config.setPasswordDefault();
config.setUrl("jdbc:mariadb://localhost:${port}/${databaseName}?useLegacyDatetimeCode=false");
config.setUrl("jdbc:mariadb://${host}:${port}/${databaseName}?useLegacyDatetimeCode=false");
config.datasourceDefaults();
return dockerProperties(config);
@@ -13,7 +13,7 @@ class MySqlSetup implements PlatformSetup {
config.setDefaultPort(defaultPort);
config.setUsernameDefault();
config.setPasswordDefault();
config.setUrl("jdbc:mysql://localhost:${port}/${databaseName}");
config.setUrl("jdbc:mysql://${host}:${port}/${databaseName}");
config.setDriver(defaultDriver());
config.datasourceDefaults();
@@ -20,7 +20,7 @@ class PostgisSetup implements PlatformSetup {
config.setUsernameDefault();
config.setPasswordDefault();
config.setDriver("org.postgis.DriverWrapperLW");
config.setUrl("jdbc:postgresql_lwgis://localhost:${port}/${databaseName}");
config.setUrl("jdbc:postgresql_lwgis://${host}:${port}/${databaseName}");
String schema = config.getSchema();
if (schema != null && !schema.equals(config.getUsername())) {
@@ -13,7 +13,7 @@ class PostgresSetup implements PlatformSetup {
config.setDefaultPort(defaultPort);
config.setUsernameDefault();
config.setPasswordDefault();
config.setUrl("jdbc:postgresql://localhost:${port}/${databaseName}");
config.setUrl("jdbc:postgresql://${host}:${port}/${databaseName}");
String schema = config.getSchema();
if (schema != null && !schema.equals(config.getUsername())) {
@@ -44,7 +44,7 @@ class PostgresSetup implements PlatformSetup {
config.setDefaultPort(defaultPort);
config.setExtraUsernameDefault();
config.setExtraDbPasswordDefault();
config.setUrl("jdbc:postgresql://localhost:${port}/${databaseName}");
config.setUrl("jdbc:postgresql://${host}:${port}/${databaseName}");
config.setDriver("org.postgresql.Driver");
config.extraDatasourceDefaults();
}
@@ -8,10 +8,14 @@ import java.util.Properties;
class RedisSetup {
static void run(Properties properties) {
String version = properties.getProperty("ebean.test.redis");
version = properties.getProperty("ebean.test.redis.version", version);
if (version != null) {
DockerHost dockerHost = new DockerHost();
if (dockerHost.runningInDocker()) {
String host = dockerHost.dockerHost(properties.getProperty("ebean.test.dockerHost"));
properties.setProperty("redis.host", host);
}
RedisConfig redisConfig = new RedisConfig(version, properties);
RedisContainer container = new RedisContainer(redisConfig);
container.start();
@@ -13,7 +13,7 @@ class SqlServerSetup implements PlatformSetup {
config.setDefaultPort(1433);
config.setUsernameDefault();
config.setPassword("SqlS3rv#r");
config.setUrl("jdbc:sqlserver://localhost:${port};databaseName=${databaseName}");
config.setUrl("jdbc:sqlserver://${host}:${port};databaseName=${databaseName};sendTimeAsDateTime=false");
config.setDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver");
config.datasourceDefaults();
@@ -27,16 +27,17 @@ public class DatabaseConfigTest {
@Test
public void evalPropertiesInput() {
String home = System.getenv("HOME");
String home = System.getProperty("user.home");
String fileSeparator = System.getProperty("file.separator");
Properties props = new Properties();
props.setProperty("ddl.initSql", "${HOME}/initSql");
props.setProperty("ddl.initSql", "${user.home}" + fileSeparator + "initSql");
DatabaseConfig config = new DatabaseConfig();
config.loadFromProperties(props);
String ddlInitSql = config.getDdlInitSql();
assertThat(ddlInitSql).isEqualTo(home+"/initSql");
assertThat(ddlInitSql).isEqualTo(home + fileSeparator + "initSql");
}
@Test
@@ -50,30 +50,31 @@ public class PropertiesWrapperTest {
@Test
public void testGetProperties() {
String home = System.getenv("HOME");
String home = System.getProperty("user.home");
String tmpDir = System.getProperty("java.io.tmpdir");
String fileSeparator = System.getProperty("file.separator");
Properties properties = new Properties();
properties.put("someBasic", "hello");
properties.put("someInt", "42");
properties.put("someDouble", "5.5");
properties.put("somePath", "${HOME}/hello");
properties.put("someSystemProp", "/aaa/${java.io.tmpdir}/bbb");
properties.put("somePath", "${user.home}" + fileSeparator + "hello");
properties.put("someSystemProp", fileSeparator + "aaa" + fileSeparator + "${java.io.tmpdir}" + fileSeparator + "bbb");
Properties evalCopy = Config.asConfiguration().eval(properties);
PropertiesWrapper pw = new PropertiesWrapper("pref", "myserver", evalCopy, null);
assertEquals(42, pw.getInt("someInt", 99));
assertEquals(Double.valueOf(5.5D), (Double.valueOf(pw.getDouble("someDouble", 99.9D))));
assertEquals(home + "/hello", pw.get("somePath", null));
assertEquals("/aaa/" + tmpDir + "/bbb", pw.get("someSystemProp"));
assertEquals(home + fileSeparator + "hello", pw.get("somePath", null));
assertEquals(fileSeparator + "aaa" + fileSeparator + tmpDir + fileSeparator + "bbb", pw.get("someSystemProp"));
pw = new PropertiesWrapper(evalCopy, null);
assertEquals(42, pw.getInt("someInt", 99));
assertEquals(Double.valueOf(5.5D), (Double.valueOf(pw.getDouble("someDouble", 99.9D))));
assertEquals(home + "/hello", pw.get("somePath", null));
assertEquals("/aaa/" + tmpDir + "/bbb", pw.get("someSystemProp"));
assertEquals(home + fileSeparator + "hello", pw.get("somePath", null));
assertEquals(fileSeparator + "aaa" + fileSeparator + tmpDir + fileSeparator + "bbb", pw.get("someSystemProp"));
}
}
@@ -2,28 +2,34 @@ package io.ebean.config.dbplatform;
import io.ebean.config.PlatformConfig;
import io.ebean.config.dbplatform.oracle.Oracle11Platform;
import io.ebean.config.dbplatform.oracle.Oracle12Platform;
import io.ebean.config.dbplatform.oracle.OraclePlatform;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class OraclePlatformTest {
class OraclePlatformTest {
@Test
public void columnAliasPrefix_Oracle11Platform() {
void columnAliasPrefix_Oracle11Platform() {
Oracle11Platform platform11 = new Oracle11Platform();
assertThat(platform11.columnAliasPrefix).isEqualTo("c");
}
@Test
public void columnAliasPrefix_OraclePlatform() {
OraclePlatform platform = new OraclePlatform();
assertThat(platform.columnAliasPrefix).isEqualTo("c");
void columnAliasPrefix_Oracle12Platform() {
Oracle12Platform platform12 = new Oracle12Platform();
assertThat(platform12.columnAliasPrefix).isEqualTo("c");
}
@Test
public void uuid_default() {
void columnAliasPrefix_OraclePlatform() {
OraclePlatform platform = new OraclePlatform();
assertThat(platform.columnAliasPrefix).isNull();
}
@Test
void uuid_default() {
OraclePlatform platform = new OraclePlatform();
platform.configure(new PlatformConfig(), false);
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
@@ -31,8 +37,7 @@ public class OraclePlatformTest {
}
@Test
public void uuid_as_binary() {
void uuid_as_binary() {
OraclePlatform platform = new OraclePlatform();
PlatformConfig config = new PlatformConfig();
config.setDbUuid(PlatformConfig.DbUuid.AUTO_BINARY);
@@ -4,24 +4,22 @@ import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import io.ebean.ModifyAwareType;
import io.ebean.text.json.EJson;
import io.ebean.util.IOUtils;
import io.ebeaninternal.json.ModifyAwareMap;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringReader;
import java.io.Writer;
import java.nio.file.Files;
import java.util.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
public class EJsonTests {
private static final Logger log = LoggerFactory.getLogger(EJsonTests.class);
@Test
public void test_map_simple() throws IOException {
@@ -46,15 +44,13 @@ public class EJsonTests {
public void write_withWriter_expect_writerNotClosed() throws IOException {
File temp = Files.createTempFile("some", ".json").toFile();
FileWriter writer = new FileWriter(temp);
Map<String,Object> map = new LinkedHashMap<>();
map.put("foo", "bar");
EJson.write(map, writer);
writer.write("The end.");
writer.flush();
writer.close();
log.info("write to file {}", temp.getAbsolutePath());
try (Writer writer = IOUtils.newWriter(temp)) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("foo", "bar");
EJson.write(map, writer);
writer.write("The end.");
}
assertThat(temp).hasContent("{\"foo\":\"bar\"}The end.");
}
@Test
@@ -0,0 +1,87 @@
package io.ebean.test.config.platform;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class DockerHostTest {
@Test
void runningInDocker_when_false_alwaysUseLocalhost() {
DockerHost dockerHost = new DockerHost();
assertFalse(dockerHost.runningInDocker());
assertEquals("localhost", dockerHost.dockerHost("foo"));
}
@Test
void runningInDocker_when_true_useExplicit() {
TDDockerHost dockerHost = new TDDockerHost();
assertTrue(dockerHost.runningInDocker());
assertEquals("my-host", dockerHost.dockerHost("my-host"));
}
@Disabled
@Test
void runningInDocker_when_trueAndLinux_useDefault() {
TDDockerHost dockerHost = new TDDockerHost();
assertTrue(dockerHost.runningInDocker());
assertEquals("172.17.0.1", dockerHost.dockerHost(null));
}
@Test
void runningInDocker_when_windowsDefault() {
TDDockerHost dockerHost = new TDDockerHost();
assertTrue(dockerHost.runningInDocker());
String origName = System.getProperty("os.name");
System.setProperty("os.name", "win");
try {
assertEquals("host.docker.internal",dockerHost.defaultDockerHost());
assertEquals("host.docker.internal", dockerHost.dockerHost(null));
} finally {
System.setProperty("os.name", origName);
}
}
@Test
void runningInDocker_when_macDefault() {
TDDockerHost dockerHost = new TDDockerHost();
assertTrue(dockerHost.runningInDocker());
String origName = System.getProperty("os.name");
System.setProperty("os.name", "mac");
try {
assertEquals("host.docker.internal",dockerHost.defaultDockerHost());
assertEquals("host.docker.internal", dockerHost.dockerHost(null));
} finally {
System.setProperty("os.name", origName);
}
}
@Test
void runningInDocker_when_linuxDefault() {
TDDockerHost dockerHost = new TDDockerHost();
assertTrue(dockerHost.runningInDocker());
String origName = System.getProperty("os.name");
System.setProperty("os.name", "linux");
try {
assertEquals("172.17.0.1",dockerHost.defaultDockerHost());
assertEquals("172.17.0.1", dockerHost.dockerHost(null));
} finally {
System.setProperty("os.name", origName);
}
}
static class TDDockerHost extends DockerHost {
@Override
boolean initInDocker() {
return true;
}
}
}
@@ -11,6 +11,7 @@ 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;
@@ -94,7 +95,7 @@ public class CachedBeanDataSerializeTest extends BaseTestCase {
TBytesOnly bean = new TBytesOnly();
bean.setId(42);
bean.setContent(stringContent.getBytes("UTF-8"));
bean.setContent(stringContent.getBytes(StandardCharsets.UTF_8));
BeanDescriptor<TBytesOnly> desc = getBeanDescriptor(TBytesOnly.class);
CachedBeanData extract = CachedBeanDataFromBean.extract(desc, (EntityBean) bean);
@@ -5,6 +5,7 @@ import io.ebean.config.EncryptKey;
import org.junit.jupiter.api.Test;
import org.tests.basic.encrypt.BasicEncryptKey;
import java.nio.charset.StandardCharsets;
import java.sql.Timestamp;
import static org.assertj.core.api.Assertions.assertThat;
@@ -19,7 +20,7 @@ public class TestSimpleEncryptor extends BaseTestCase {
EncryptKey key = new BasicEncryptKey("hello");
byte[] data = "test123".getBytes();
byte[] data = "test123".getBytes(StandardCharsets.UTF_8);
byte[] ecData = e.encrypt(data, key);
@@ -15,6 +15,8 @@ import org.tests.model.ivo.converter.MoneyTypeConverter;
import javax.persistence.EnumType;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Calendar;
import java.util.GregorianCalendar;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
@@ -29,7 +31,6 @@ public class TestTypeManager extends BaseTestCase {
DefaultTypeManager typeManager = createTypeManager();
ScalarType<?> type = typeManager.createEnumScalarType(MyEnum.class, null);
typeManager.addEnumType(type, MyEnum.class);
Object val = type.read(new DummyDataReader("A"));
assertThat(val).isEqualTo(MyEnum.Aval);
@@ -131,6 +132,13 @@ public class TestTypeManager extends BaseTestCase {
return new DefaultTypeManager(config, bootupClasses);
}
@Test
public void testCalendar() throws SQLException {
DefaultTypeManager typeManager = createTypeManager();
ScalarType<?> typeB = typeManager.getScalarType(GregorianCalendar.class);
assertThat(typeB).isInstanceOf(ScalarTypeCalendar.class);
}
/**
* Test double DataReader implementation.
*/
@@ -8,12 +8,14 @@ import org.tests.model.basic.PFileContent;
import static org.junit.jupiter.api.Assertions.assertNull;
import java.nio.charset.StandardCharsets;
public class TestDeleteImportedPartial extends BaseTestCase {
@Test
public void test() {
PFile persistentFile = new PFile("test.txt", new PFileContent("test".getBytes()));
PFile persistentFile = new PFile("test.txt", new PFileContent("test".getBytes(StandardCharsets.UTF_8)));
DB.save(persistentFile);
Integer id = persistentFile.getId();
@@ -8,13 +8,15 @@ import org.tests.model.basic.PersistentFileContent;
import static org.junit.jupiter.api.Assertions.assertNull;
import java.nio.charset.StandardCharsets;
public class TestDeleteOneToOne extends BaseTestCase {
@Test
public void testCreateDeletePersistentFile() {
PersistentFile persistentFile = new PersistentFile("test.txt", new PersistentFileContent(
"test".getBytes()));
"test".getBytes(StandardCharsets.UTF_8)));
DB.save(persistentFile);
Integer id = persistentFile.getId();
@@ -8,16 +8,18 @@ import org.tests.model.basic.PFileContent;
import static org.junit.jupiter.api.Assertions.assertNull;
import java.nio.charset.StandardCharsets;
public class TestDeleteOneToOneMultiple extends BaseTestCase {
@Test
public void testCreateDeletePersistentFile() {
PFile persistentFile = new PFile("test.txt", new PFileContent("test".getBytes()));
PFile persistentFile = new PFile("test.txt", new PFileContent("test".getBytes(StandardCharsets.UTF_8)));
// PFile persistentFile = new PFile();
// persistentFile.setName("test.txt");
// PFileContent content = new PFileContent();
// content.setContent("test".getBytes());
// content.setContent("test".getBytes(StandardCharsets.UTF_8));
// persistentFile.setFileContent(content);
DB.save(persistentFile);
@@ -8,12 +8,14 @@ import org.tests.model.basic.PersistentFileContent;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.nio.charset.StandardCharsets;
public class TestSaveDeleteOneToOne extends BaseTestCase {
@Test
public void testCreateDeletePersistentFile() {
PersistentFile persistentFile = new PersistentFile("test.txt",
new PersistentFileContent("test".getBytes()));
new PersistentFileContent("test".getBytes(StandardCharsets.UTF_8)));
DB.save(persistentFile);
DB.delete(persistentFile);
@@ -22,7 +24,7 @@ public class TestSaveDeleteOneToOne extends BaseTestCase {
@Test
public void testCreateLoadDeletePersistentFile() {
PersistentFile persistentFile = new PersistentFile("test.txt",
new PersistentFileContent("test".getBytes()));
new PersistentFileContent("test".getBytes(StandardCharsets.UTF_8)));
DB.save(persistentFile);
@@ -8,11 +8,13 @@ import org.tests.model.basic.PFileContent;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.nio.charset.StandardCharsets;
public class TestSaveDeleteOneToOneMultiple extends BaseTestCase {
// public void testCreateDeletePFile() {
// PFile persistentFile = new PFile("test.txt",
// new PFileContent("test".getBytes()));
// new PFileContent("test".getBytes(StandardCharsets.UTF_8)));
//
// DB.save(persistentFile);
// DB.delete(persistentFile);
@@ -21,7 +23,7 @@ public class TestSaveDeleteOneToOneMultiple extends BaseTestCase {
@Test
public void testCreateLoadDeletePFile() {
PFile persistentFile = new PFile("test.txt",
new PFileContent("test".getBytes()));
new PFileContent("test".getBytes(StandardCharsets.UTF_8)));
DB.save(persistentFile);
@@ -6,6 +6,7 @@ import io.ebean.DB;
import org.junit.jupiter.api.Test;
import org.tests.model.basic.TWithPreInsert;
import org.tests.model.basic.TWithPreInsertChild;
import org.tests.model.basic.event.TWithPreInsertPersistAdapter;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -27,6 +28,7 @@ class TestPreInsertValidation extends BaseTestCase {
assertThat(e.requestCascadeState()).isEqualTo(2);
TWithPreInsert e1 = DB.find(TWithPreInsert.class, e.getId());
assert e1 != null;
e1.setTitle("Missus");
DB.save(e1);
@@ -54,11 +56,21 @@ class TestPreInsertValidation extends BaseTestCase {
assert e1 != null;
e1.setTitle("ParentCascading-changed");
e1.children().get(0).setName("Child0-changed");
TWithPreInsertChild childBean = e1.children().get(0);
childBean.setName("Child0-changed");
DB.save(e1);
assertThat(e1.requestCascadeState()).isEqualTo(12);
assertThat(e1.children().get(0).requestCascadeState()).isEqualTo(11);
assertThat(childBean.requestCascadeState()).isEqualTo(11);
DB.delete(e1);
assertThat(e1.requestCascadeState()).isEqualTo(22);
// assert that isCascade() was true for the child bean
assertThat(TWithPreInsertPersistAdapter.cascadeDelete).hasSize(1);
String deleteCascade = TWithPreInsertPersistAdapter.cascadeDelete.get(0);
assertThat(deleteCascade).isEqualTo("class org.tests.model.basic.TWithPreInsertChild:1");
}
@Test
@@ -26,7 +26,7 @@ public class TestDefaults extends BaseTestCase {
final List<String> current = LoggedSql.collect();
assertThat(current).isNotEmpty();
if (isMySql() || isMariaDB()) {
if (isMySql() || isMariaDB() || isOracle()) {
assertThat(current.get(0)).contains("insert into defaults_model_draft values (default);");
} else if (isSqlServer()) {
assertThat(current.get(0)).contains("insert into defaults_model_draft (id) values (?)");
@@ -9,12 +9,14 @@ import org.tests.model.basic.PFileContent;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.nio.charset.StandardCharsets;
public class TestConstructorPutfieldReplacement extends BaseTestCase {
@Test
public void test() {
PFile persistentFile = new PFile("test.txt", new PFileContent("test".getBytes()));
PFile persistentFile = new PFile("test.txt", new PFileContent("test".getBytes(StandardCharsets.UTF_8)));
EntityBean eb = (EntityBean) persistentFile;
EntityBeanIntercept ebi = eb._ebean_getIntercept();
@@ -14,6 +14,8 @@ import org.tests.idkeys.db.GenKeySeqB;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
@@ -24,6 +26,7 @@ public class TestGeneratedKeys extends BaseTestCase {
@ForPlatform(Platform.H2) // readSequenceValue is H2 specific
public void testGenKeySeqA() throws SQLException {
assumeTrue(idType() == IdType.SEQUENCE);
SpiEbeanServer server = spiEbeanServer();
try (Transaction tx = server.beginTransaction()) {
@@ -69,20 +72,34 @@ public class TestGeneratedKeys extends BaseTestCase {
}
private long readSequenceValue(Transaction tx, String sequence) throws SQLException {
Statement stm = null;
try {
stm = tx.connection().createStatement();
ResultSet rs = stm.executeQuery("select currval('" + sequence + "')");
rs.next();
String sql;
switch (spiEbeanServer().databasePlatform().getPlatform().base()) {
case H2 :
sql = "select currval('" + sequence + "')";
break;
case DB2 :
sql = "values previous value for " + sequence;
break;
case SQLSERVER :
sql = "select current_value from sys.sequences where name = '" + sequence + "'";
break;
case MARIADB :
throw new UnsupportedOperationException("reading sequence value outside of the current connection is not supported. "
+ "See https://mariadb.com/kb/en/previous-value-for-sequence_name/#description");
default :
throw new UnsupportedOperationException("reading sequence value from "
+ spiEbeanServer().databasePlatform().getPlatform()
+ " is not supported.");
}
try (Statement stm = tx.connection().createStatement()) {
ResultSet rs = stm.executeQuery(sql);
rs.next();
return rs.getLong(1);
} finally {
if (stm != null) {
try {
stm.close();
} catch (SQLException e) {
}
}
}
}
@@ -109,5 +126,25 @@ public class TestGeneratedKeys extends BaseTestCase {
assertNotNull(al.getId());
}
}
@Test
@ForPlatform({Platform.H2, Platform.MARIADB, Platform.SQLSERVER, Platform.DB2})
public void testGeneratedKeys() throws SQLException {
assumeTrue(idType() == IdType.SEQUENCE);
SpiEbeanServer server = spiEbeanServer();
List<Long> idList = new ArrayList<>(52);
try (Transaction tx = server.beginTransaction()) {
// bigger than increment
for (int i = 1; i < 52; i++) {
GenKeySeqA gks = new GenKeySeqA();
gks.setDescription("my description " + i);
server.save(gks);
assertFalse(idList.contains(gks.getId()));
idList.add(gks.getId());
}
}
}
}
@@ -7,7 +7,7 @@ import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import static javax.persistence.CascadeType.PERSIST;
import static javax.persistence.CascadeType.ALL;
@Entity
public class TWithPreInsert implements TWithPreInsertCommon {
@@ -20,7 +20,7 @@ public class TWithPreInsert implements TWithPreInsertCommon {
private String title;
@OneToMany(cascade = PERSIST)
@OneToMany(cascade = ALL)
private List<TWithPreInsertChild> children = new ArrayList<>();
/**
@@ -2,6 +2,8 @@ package org.tests.model.basic;
public interface TWithPreInsertCommon {
Integer getId();
String getName();
void setName(String name);
@@ -4,8 +4,13 @@ import io.ebean.event.BeanPersistAdapter;
import io.ebean.event.BeanPersistRequest;
import org.tests.model.basic.TWithPreInsertCommon;
import java.util.ArrayList;
import java.util.List;
public class TWithPreInsertPersistAdapter extends BeanPersistAdapter {
public static List<String> cascadeDelete = new ArrayList<>();
@Override
public boolean isRegisterFor(Class<?> cls) {
return TWithPreInsertCommon.class.isAssignableFrom(cls);
@@ -32,4 +37,14 @@ public class TWithPreInsertPersistAdapter extends BeanPersistAdapter {
return super.preUpdate(request);
}
@Override
public boolean preDelete(BeanPersistRequest<?> request) {
TWithPreInsertCommon bean = (TWithPreInsertCommon) request.bean();
if (request.isCascade()) {
cascadeDelete.add(bean.getClass() + ":" + bean.getId());
} else {
bean.requestCascadeState(22);
}
return true;
}
}
@@ -0,0 +1,61 @@
package org.tests.model.elementcollection;
import io.ebean.annotation.Cache;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Cache
@Entity
public class EcblPerson2 {
@Id
long id;
String name;
@ElementCollection
@CollectionTable(joinColumns = @JoinColumn(name = "person_id"))
List<EcPhone> phoneNumbers = new ArrayList<>();
@Version
long version;
@Override
public String toString() {
return "person id:" + id + " name:" + name + " phs:" + phoneNumbers;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<EcPhone> getPhoneNumbers() {
return phoneNumbers;
}
public void setPhoneNumbers(List<EcPhone> phoneNumbers) {
this.phoneNumbers = phoneNumbers;
}
public long getVersion() {
return version;
}
public void setVersion(long version) {
this.version = version;
}
}
@@ -9,10 +9,10 @@ import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class TestElementCollectionEmbeddedListCache extends BaseTestCase {
class TestElementCollectionEmbeddedListCache extends BaseTestCase {
@Test
public void test() {
void test() {
EcblPerson person = new EcblPerson("CacheL");
person.getPhoneNumbers().add(new EcPhone("64", "021","1234"));
@@ -86,12 +86,10 @@ public class TestElementCollectionEmbeddedListCache extends BaseTestCase {
assertThat(four.getPhoneNumbers().toString()).contains("61-07-11");
assertThat(four.getPhoneNumbers()).hasSize(1);
DB.delete(four);
sql = LoggedSql.collect();
assertThat(sql).hasSize(2);
LoggedSql.stop();
}
}
@@ -0,0 +1,99 @@
package org.tests.model.elementcollection;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.test.LoggedSql;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
class TestElementCollectionEmbeddedListCache2 extends BaseTestCase {
@Test
void test() {
EcblPerson2 person = new EcblPerson2();
person.setName("CacheL");
person.getPhoneNumbers().add(new EcPhone("64", "021","1234"));
person.getPhoneNumbers().add(new EcPhone("64","021","4321"));
DB.save(person);
EcblPerson2 one = DB.find(EcblPerson2.class)
.setId(person.getId())
.fetch("phoneNumbers")
.findOne();
LoggedSql.start();
one.getPhoneNumbers().size();
List<String> sql = LoggedSql.collect();
assertThat(sql).isEmpty();
EcblPerson2 two = DB.find(EcblPerson2.class )
.setId(person.getId())
.findOne();
two.getPhoneNumbers().size();
assertThat(two.getPhoneNumbers().toString()).contains("64-021-1234", "64-021-4321");
sql = LoggedSql.collect();
assertThat(sql).isEmpty(); // cache hit
two.getPhoneNumbers().add(new EcPhone("61", "07", "11"));
two.getPhoneNumbers().remove(1);
DB.save(two);
sql = LoggedSql.collect();
if (isPersistBatchOnCascade()) {
assertThat(sql).hasSize(5); // update of collection only
assertSql(sql.get(0)).contains("delete from ecbl_person2_phone_numbers where person_id=?");
assertSqlBind(sql.get(1));
assertSql(sql.get(2)).contains("insert into ecbl_person2_phone_numbers (person_id,country_code,area,phnum) values (?,?,?,?)");
assertSqlBind(sql, 3, 4);
} else {
assertThat(sql).hasSize(3); // update of collection only
assertSql(sql.get(0)).contains("delete from ecbl_person2_phone_numbers where person_id=?");
assertSql(sql.get(1)).contains("insert into ecbl_person2_phone_numbers (person_id,country_code,area,phnum) values (?,?,?,?)");
assertSql(sql.get(2)).contains("insert into ecbl_person2_phone_numbers (person_id,country_code,area,phnum) values (?,?,?,?)");
}
EcblPerson2 three = DB.find(EcblPerson2.class )
.setId(person.getId())
.findOne();
assertThat(three.getPhoneNumbers().toString()).contains("61-07-11", "64-021-1234");
assertThat(three.getPhoneNumbers()).hasSize(2);
sql = LoggedSql.collect();
assertThat(sql).isEmpty(); // cache hit
three.setName("mod-3");
three.getPhoneNumbers().remove(0);
DB.save(three);
sql = LoggedSql.collect();
assertThat(sql).hasSize(5);
EcblPerson2 four = DB.find(EcblPerson2.class )
.setId(person.getId())
.findOne();
assertThat(four.getPhoneNumbers().toString()).contains("61-07-11");
assertThat(four.getPhoneNumbers()).hasSize(1);
DB.delete(four);
sql = LoggedSql.collect();
assertThat(sql).hasSize(2);
LoggedSql.stop();
}
}
@@ -0,0 +1,31 @@
package org.tests.model.embedded;
import io.ebean.annotation.DbArray;
import javax.persistence.*;
import java.util.List;
@Entity
public class EmbArrayMaster {
@Embeddable
public static class EmbArrayDetail {
@DbArray
List<String> vals;
public EmbArrayDetail(List<String> vals) {
this.vals = vals;
}
}
@Id
int id;
@ElementCollection
@CollectionTable(name = "test_array_detail", joinColumns = {@JoinColumn(name = "master_id")})
List<EmbArrayDetail> details;
public EmbArrayMaster(List<EmbArrayDetail> details) {
this.details = details;
}
}
@@ -0,0 +1,21 @@
package org.tests.model.embedded;
import io.ebean.DB;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
class TestEmbeddedDbArray {
/**
* Failing test case for #2477
*/
@Disabled
@Test
void testArrayInsert() {
EmbArrayMaster t = new EmbArrayMaster(singletonList(new EmbArrayMaster.EmbArrayDetail(emptyList())));
DB.insert(t);
}
}
@@ -33,7 +33,7 @@ public class MnyNode {
joinColumns = @JoinColumn(name = "from_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "to_id", referencedColumnName = "id"))
@Where(clause = "${mta}.flags & 1 != 0")
@Where(clause = "BITAND(${mta}.flags, 1) != 0", platforms = Platform.H2)
@Where(clause = "BITAND(${mta}.flags, 1) != 0", platforms = {Platform.H2, Platform.ORACLE})
List<MnyNode> bit1Relations;
@ManyToMany
@@ -41,7 +41,7 @@ public class MnyNode {
joinColumns = @JoinColumn(name = "to_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "from_id", referencedColumnName = "id"))
@Where(clause = "${mta}.flags & 1 != 0")
@Where(clause = "BITAND(${mta}.flags, 1) != 0", platforms = Platform.H2)
@Where(clause = "BITAND(${mta}.flags, 1) != 0", platforms = {Platform.H2, Platform.ORACLE})
List<MnyNode> bit1ReverseRelations;
@ManyToMany
@@ -49,7 +49,7 @@ public class MnyNode {
joinColumns = @JoinColumn(name = "from_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "to_id", referencedColumnName = "id"))
@Where(clause = "${mta}.flags & 2 != 0")
@Where(clause = "BITAND(${mta}.flags, 2) != 0", platforms = Platform.H2)
@Where(clause = "BITAND(${mta}.flags, 2) != 0", platforms = {Platform.H2, Platform.ORACLE})
List<MnyNode> bit2Relations;
@ManyToMany
@@ -57,7 +57,7 @@ public class MnyNode {
joinColumns = @JoinColumn(name = "to_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "from_id", referencedColumnName = "id"))
@Where(clause = "${mta}.flags & 2 != 0")
@Where(clause = "BITAND(${mta}.flags, 2) != 0", platforms = Platform.H2)
@Where(clause = "BITAND(${mta}.flags, 2) != 0", platforms = {Platform.H2, Platform.ORACLE})
List<MnyNode> bit2ReverseRelations;
@ManyToMany
@@ -7,6 +7,7 @@ import javax.persistence.Version;
import java.nio.file.Path;
import java.sql.Date;
import java.time.*;
import java.util.Calendar;
@Entity
public class SomeNewTypesBean {
@@ -58,6 +59,8 @@ public class SomeNewTypesBean {
Duration duration;
Calendar calendar;
public Long getId() {
return id;
}
@@ -217,4 +220,12 @@ public class SomeNewTypesBean {
public void setDuration(Duration duration) {
this.duration = duration;
}
public Calendar getCalendar() {
return calendar;
}
public void setCalendar(final Calendar calendar) {
this.calendar = calendar;
}
}
@@ -12,14 +12,12 @@ import java.util.ArrayList;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class ParentQueryTest extends BaseTestCase {
class ParentQueryTest extends BaseTestCase {
@Test
public void QueryParentCollectionFetch() {
void queryParentCollectionFetch() {
List<Data> exampleData = new ArrayList<>();
exampleData.add(new Data(0));
exampleData.add(new Data(1));
@@ -40,7 +38,7 @@ public class ParentQueryTest extends BaseTestCase {
List<Parent> partial = DB.find(Parent.class).where().ge("val", 1001).findList();
assertNotNull(partial.get(0).getData());
assertThat(partial.get(0).getMore()).startsWith("PQT-");
assertEquals(partial.get(0).getData().get(0).getVal().intValue(), 0);
assertThat(partial.get(0).getData()).hasSize(3);
}
}

Some files were not shown because too many files have changed in this diff Show More