Skip to content

Commit

Permalink
Merge branch 'master-upstream'
Browse files Browse the repository at this point in the history
# Conflicts:
#	composites/ebean/pom.xml
#	ebean-bom/pom.xml
#	ebean-core/pom.xml
#	ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
#	ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java
#	ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java
#	ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationClass.java
#	ebean-core/src/main/java/io/ebeaninternal/server/persist/dml/DmlBeanPersister.java
#	ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java
#	ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeOffsetDateTime.java
#	ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeTimestamp.java
#	ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DdlPlugin.java
#	ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DefaultDbMigration.java
#	ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/idx_db2.migrations
#	ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/idx_db2.migrations
#	ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/idx_db2.migrations
#	tests/test-java16/pom.xml
  • Loading branch information
nPraml committed Oct 21, 2022
2 parents 1d332af + 7152cf6 commit 0ebbab2
Show file tree
Hide file tree
Showing 591 changed files with 4,440 additions and 4,526 deletions.
4 changes: 0 additions & 4 deletions composites/ebean-postgres/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,4 @@
</dependency>

</dependencies>

<scm>
<tag>ebean-parent-13.6.4-FOC1</tag>
</scm>
</project>
4 changes: 0 additions & 4 deletions composites/ebean-sqlite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,4 @@
</dependency>

</dependencies>

<scm>
<tag>ebean-parent-13.6.4-FOC1</tag>
</scm>
</project>
4 changes: 0 additions & 4 deletions composites/ebean-sqlserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,4 @@
</dependency>

</dependencies>

<scm>
<tag>ebean-parent-13.6.4-FOC1</tag>
</scm>
</project>
4 changes: 0 additions & 4 deletions composites/ebean-yugabyte/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,4 @@
</dependency>

</dependencies>

<scm>
<tag>ebean-parent-13.6.4-FOC1</tag>
</scm>
</project>
18 changes: 18 additions & 0 deletions composites/ebean/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@
<version>13.10.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-joda-time</artifactId>
<version>13.10.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-jackson-jsonnode</artifactId>
<version>13.10.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-jackson-mapper</artifactId>
<version>13.10.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource</artifactId>
Expand Down
32 changes: 18 additions & 14 deletions ebean-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,23 @@

<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.36</version>
<scope>provided</scope>
<groupId>io.avaje</groupId>
<artifactId>avaje-applog</artifactId>
<version>1.0</version>
</dependency>

<!-- exclude avaje-applog-slf4j to direct logging to something else -->
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-config</artifactId>
<version>2.2</version>
<artifactId>avaje-applog-slf4j</artifactId>
<version>1.0</version>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-applog-slf4j</artifactId>
<version>1.0</version>
<artifactId>avaje-config</artifactId>
<version>2.2</version>
</dependency>

<!--
Expand All @@ -49,7 +45,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>persistence-api</artifactId>
<version>3.0</version>
<version>${ebean-persistence-api.version}</version>
</dependency>

<dependency>
Expand All @@ -61,7 +57,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-types</artifactId>
<version>3.0</version>
<version>${ebean-types.version}</version>
</dependency>

<dependency>
Expand All @@ -70,6 +66,14 @@
<version>${ebean-datasource.version}</version>
</dependency>

<!-- Support MdcBackgroundExecutorWrapper -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
<optional>true</optional>
</dependency>

<!-- Jackson core used internally by Ebean -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down
7 changes: 0 additions & 7 deletions ebean-api/src/main/java/io/ebean/DB.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import io.ebean.annotation.TxIsolation;
import io.ebean.cache.ServerCacheManager;
import io.ebean.plugin.Property;
import io.ebean.text.csv.CsvReader;
import io.ebean.text.json.JsonContext;

import javax.persistence.OptimisticLockException;
Expand Down Expand Up @@ -798,12 +797,6 @@ public static <T> Update<T> createUpdate(Class<T> beanType, String ormUpdate) {
return getDefault().createUpdate(beanType, ormUpdate);
}

/**
* Create a CsvReader for a given beanType.
*/
public static <T> CsvReader<T> createCsvReader(Class<T> beanType) {
return getDefault().createCsvReader(beanType);
}

/**
* Create a named query.
Expand Down
5 changes: 0 additions & 5 deletions ebean-api/src/main/java/io/ebean/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import io.ebean.meta.MetaInfoManager;
import io.ebean.plugin.Property;
import io.ebean.plugin.SpiServer;
import io.ebean.text.csv.CsvReader;
import io.ebean.text.json.JsonContext;

import javax.persistence.OptimisticLockException;
Expand Down Expand Up @@ -204,10 +203,6 @@ public interface Database {
*/
<T> T createEntityBean(Class<T> type);

/**
* Create a CsvReader for a given beanType.
*/
<T> CsvReader<T> createCsvReader(Class<T> beanType);

/**
* Create an Update query to perform a bulk update.
Expand Down
19 changes: 7 additions & 12 deletions ebean-api/src/main/java/io/ebean/DbContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,30 @@

import io.ebean.config.BeanNotEnhancedException;
import io.ebean.datasource.DataSourceConfigurationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.persistence.PersistenceException;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;

import static java.lang.System.Logger.Level.ERROR;

/**
* Holds Database instances.
*/
final class DbContext {

private static final Logger log = LoggerFactory.getLogger("io.ebean");
private static final System.Logger log = EbeanVersion.log;
static {
EbeanVersion.getVersion();
}

private static final DbContext INSTANCE = new DbContext();

private final ConcurrentHashMap<String, Database> concMap = new ConcurrentHashMap<>();

private final HashMap<String, Database> syncMap = new HashMap<>();

private final ReentrantLock lock = new ReentrantLock();

/**
* The 'default' Database.
*/
private Database defaultDatabase;

private DbContext() {
Expand All @@ -52,7 +47,7 @@ private DbContext() {
throw new DataSourceConfigurationException(msg, e);

} catch (Throwable e) {
log.error("Error trying to create the default Database", e);
log.log(ERROR, "Error trying to create the default Database", e);
throw new RuntimeException(e);
}
}
Expand All @@ -69,9 +64,9 @@ static DbContext getInstance() {
*/
Database getDefault() {
if (defaultDatabase == null) {
String msg = "The default Database has not been defined?";
msg += " This is normally set via the ebean.datasource.default property.";
msg += " Otherwise it should be registered programmatically via registerServer()";
String msg = "The default Database has not been defined?"
+ " This is normally set via the ebean.datasource.default property."
+ " Otherwise it should be registered programmatically via registerServer()";
throw new PersistenceException(msg);
}
return defaultDatabase;
Expand Down
22 changes: 22 additions & 0 deletions ebean-api/src/main/java/io/ebean/DuplicateKeyException.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

/**
* Thrown when a duplicate is attempted on a unique constraint.
* <p>
* In terms of catching this exception with the view of continuing processing
* using the same transaction look to use {@link Transaction#rollbackAndContinue()}.
*
* <pre>{@code
*
* try (Transaction txn = database.beginTransaction()) {
*
* try {
* ...
* database.save(bean);
* database.flush();
* } catch (DuplicateKeyException e) {
* // carry on processing using the transaction
* txn.rollbackAndContinue();
* ...
* }
*
* txn.commit();
* }
*
* }</pre>
*/
public class DuplicateKeyException extends DataIntegrityException {
private static final long serialVersionUID = -4771932723285724817L;
Expand Down
21 changes: 13 additions & 8 deletions ebean-api/src/main/java/io/ebean/EbeanVersion.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
package io.ebean;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.avaje.applog.AppLog;

import java.io.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.Properties;

import static java.lang.System.Logger.Level.*;

/**
* Class to determine the ebean version.
*
* @author Roland Praml, FOCONIS AG
*/
public final class EbeanVersion {

private static final Logger log = LoggerFactory.getLogger("io.ebean");
public static final System.Logger log = AppLog.getLogger("io.ebean");

/**
* Maintain the minimum ebean-agent version manually based on required ebean-agent bug fixes.
*/
private static final int MIN_AGENT_MAJOR_VERSION = 12;
private static final int MIN_AGENT_MINOR_VERSION = 12;
private static String version = "unknown";

static {
readVersion();
checkAgentVersion();
Expand All @@ -32,12 +37,12 @@ private static void readVersion() {
if (in != null) {
try (LineNumberReader reader = new LineNumberReader(new InputStreamReader(in))) {
version = reader.readLine();
log.log(INFO, "ebean version: {0}", version);
}
}
}
log.info("ebean version: {}", version);
} catch (IOException e) {
log.warn("Could not determine ebean version: {}", e.getMessage());
log.log(WARNING, "Could not determine ebean version: {0}", e.getMessage());
}
}

Expand All @@ -49,13 +54,13 @@ private static void checkAgentVersion() {
String agentVersion = readVersion(in);
if (agentVersion != null) {
if (checkMinAgentVersion(agentVersion)) {
log.error("Expected minimum ebean-agent version {}.{}.0 but we have {}, please update the ebean-agent", MIN_AGENT_MAJOR_VERSION, MIN_AGENT_MINOR_VERSION, agentVersion);
log.log(ERROR, "Expected minimum ebean-agent version {0}.{1}.0 but we have {2}, please update the ebean-agent", MIN_AGENT_MAJOR_VERSION, MIN_AGENT_MINOR_VERSION, agentVersion);
}
}
}
}
} catch (IOException e) {
log.warn("Could not check minimum ebean-agent version {}.{}.0 required due to - {}", MIN_AGENT_MAJOR_VERSION, MIN_AGENT_MINOR_VERSION, e.getMessage());
log.log(WARNING, "Could not check minimum ebean-agent version {0}.{1}.0 required due to - {2}", MIN_AGENT_MAJOR_VERSION, MIN_AGENT_MINOR_VERSION, e.getMessage());
}
}

Expand Down
3 changes: 2 additions & 1 deletion ebean-api/src/main/java/io/ebean/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ enum LockWait {
<A> Set<A> findSingleAttributeSet();

/**
* Execute a query returning a single value of a single property/column.
* Execute a query returning a single value or null for a single property/column.
* <p>
* <pre>{@code
*
Expand All @@ -943,6 +943,7 @@ enum LockWait {
*
* }</pre>
*/
@Nullable
<A> A findSingleAttribute();

/**
Expand Down
29 changes: 29 additions & 0 deletions ebean-api/src/main/java/io/ebean/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,35 @@ static Transaction current() {
*/
void rollback(Throwable e) throws PersistenceException;

/**
* Performs a rollback on the underlying JDBC connection with the intention of
* continuing to use this same transaction and performing a commit or rollback
* later to complete the transaction.
* <p>
* Typically used when catching {@link DuplicateKeyException} where we wish to
* rollback work done at that point but carry on processing using the transaction.
*
* <pre>{@code
*
* try (Transaction txn = database.beginTransaction()) {
*
* try {
* ...
* database.save(bean);
* database.flush();
* } catch (DuplicateKeyException e) {
* // carry on processing using the transaction
* txn.rollbackAndContinue();
* ...
* }
*
* txn.commit();
* }
*
* }</pre>
*/
void rollbackAndContinue();

/**
* Set when we want nested transactions to use Savepoint's.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public TableName getM2MJoinTableName(TableName lhsTable, TableName rhsTable) {
}
buffer.append(rhsTableName);

int maxTableNameLength = databasePlatform.getMaxTableNameLength();
int maxTableNameLength = databasePlatform.maxTableNameLength();

// maxConstraintNameLength is used as the max table name length.
if (buffer.length() > maxTableNameLength) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
* BackgroundExecutorWrapper that can be used to wrap tasks that are sent to background (i.e. another thread).
* It should copy all necessary thread-local variables. See {@link MdcBackgroundExecutorWrapper} for implementation details.
*
* Note: only tasks that are executed immediately (submit, execute) are wrapped. Periodic or scheduled tasks are not wrapped,
* as these may keep copied variables in memory either forever or until the scheduled task is finished.
* The caller is responsible to handle these cases.
*
* @author Roland Praml, FOCONIS AG
*/
public interface BackgroundExecutorWrapper {
Expand Down
Loading

0 comments on commit 0ebbab2

Please sign in to comment.