mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-26 15:21:57 +00:00
Merge branch 'master' of github.com:FOCONIS/ebean
This commit is contained in:
commit
5a2632e7ba
107 files changed
+639
-1004
No files matched your search
@@ -391,6 +391,11 @@ public interface SpiQuery<T> extends Query<T>, SpiQueryFetch, TxnProfileEventCod
|
||||
*/
|
||||
void incrementAsOfTableCount();
|
||||
|
||||
/**
|
||||
* Increment the counter of tables used in 'As Of' query.
|
||||
*/
|
||||
void incrementAsOfTableCount(int asOfTableCount);
|
||||
|
||||
/**
|
||||
* Return the table alias used for the base table.
|
||||
*/
|
||||
|
||||
@@ -312,11 +312,6 @@ public abstract class SpiTransactionProxy implements SpiTransaction {
|
||||
transaction.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushBatch() throws PersistenceException {
|
||||
flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection connection() {
|
||||
return transaction.connection();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.ebeaninternal.server.core;
|
||||
|
||||
import io.ebean.EbeanServer;
|
||||
import io.ebean.Database;
|
||||
import io.ebeaninternal.api.CoreLog;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.api.SpiTransaction;
|
||||
@@ -79,7 +79,7 @@ public abstract class BeanRequest {
|
||||
* Return the server processing the request. Made available for
|
||||
* BeanController and BeanFinder.
|
||||
*/
|
||||
public EbeanServer getEbeanServer() {
|
||||
public Database database() {
|
||||
return server;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import javax.sql.DataSource;
|
||||
*/
|
||||
final class InitDataSource {
|
||||
|
||||
private final JndiDataSourceLookup jndiDataSourceFactory = new JndiDataSourceLookup();
|
||||
private final DatabaseConfig config;
|
||||
|
||||
/**
|
||||
@@ -41,21 +40,9 @@ final class InitDataSource {
|
||||
* Initialise the "main" read write DataSource from configuration.
|
||||
*/
|
||||
private DataSource initDataSource() {
|
||||
final String jndiName = config.getDataSourceJndiName();
|
||||
if (jndiName != null) {
|
||||
return jndiDataSource(jndiName);
|
||||
}
|
||||
return createFromConfig(config.getDataSourceConfig(), false);
|
||||
}
|
||||
|
||||
private DataSource jndiDataSource(String jndiName) {
|
||||
DataSource ds = jndiDataSourceFactory.lookup(jndiName);
|
||||
if (ds == null) {
|
||||
throw new PersistenceException("JNDI lookup for DataSource " + jndiName + " returned null.");
|
||||
}
|
||||
return ds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the "read only" DataSource from configuration.
|
||||
*/
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package io.ebeaninternal.server.core;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* Helper to lookup a DataSource from JNDI.
|
||||
*/
|
||||
class JndiDataSourceLookup {
|
||||
|
||||
/**
|
||||
* Return the DataSource by JNDI lookup.
|
||||
* <p>
|
||||
* If name is null the 'default' dataSource is returned.
|
||||
* </p>
|
||||
*/
|
||||
public DataSource lookup(String jndiName) {
|
||||
try {
|
||||
Context ctx = new InitialContext();
|
||||
DataSource ds = (DataSource) ctx.lookup(jndiName);
|
||||
if (ds == null) {
|
||||
throw new PersistenceException("JNDI DataSource [" + jndiName + "] not found?");
|
||||
}
|
||||
return ds;
|
||||
|
||||
} catch (NamingException ex) {
|
||||
throw new PersistenceException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ public class BootupClasses implements Predicate<Class<?>> {
|
||||
public void runServerConfigStartup(DatabaseConfig config) {
|
||||
for (Class<?> cls : serverConfigStartupCandidates) {
|
||||
try {
|
||||
ServerConfigStartup newInstance = (ServerConfigStartup) cls.newInstance();
|
||||
ServerConfigStartup newInstance = (ServerConfigStartup) cls.getDeclaredConstructor().newInstance();
|
||||
newInstance.onStart(config);
|
||||
} catch (Exception e) {
|
||||
// assume that the desired behavior is to fail - add your own try catch if needed
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ class BeanDescriptorElementEmbedded<T> extends BeanDescriptorElement<T> {
|
||||
BeanDescriptorElementEmbedded(BeanDescriptorMap owner, DeployBeanDescriptor<T> deploy, ElementHelp elementHelp) {
|
||||
super(owner, deploy, elementHelp);
|
||||
try {
|
||||
this.prototype = (EntityBean) beanType.newInstance();
|
||||
this.prototype = (EntityBean) beanType.getDeclaredConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("Unable to create entity bean prototype for "+beanType);
|
||||
}
|
||||
|
||||
@@ -119,6 +119,11 @@ public interface DbSqlContext {
|
||||
*/
|
||||
boolean isIncludeSoftDelete();
|
||||
|
||||
/**
|
||||
* Return the count of history table AS OF predicates added via joins.
|
||||
*/
|
||||
int asOfTableCount();
|
||||
|
||||
/**
|
||||
* Return true if the query is a 'asDraft' query.
|
||||
*/
|
||||
|
||||
-11
@@ -100,22 +100,11 @@ public final class DefaultBackgroundExecutor implements SpiBackgroundExecutor {
|
||||
return pool.submit(wrap(task));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Runnable task) {
|
||||
submit(logExceptions(task));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executePeriodically(Runnable task, long delay, TimeUnit unit) {
|
||||
schedulePool.scheduleWithFixedDelay(wrap(logExceptions(task)), delay, delay, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executePeriodically(Runnable task, long initialDelay, long delay, TimeUnit unit) {
|
||||
schedulePool.scheduleWithFixedDelay(wrap(logExceptions(task)), initialDelay, delay, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, long initialDelay, long delay, TimeUnit unit) {
|
||||
return schedulePool.scheduleWithFixedDelay(wrap(logExceptions(task)), initialDelay, delay, unit);
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package io.ebeaninternal.server.persist;
|
||||
|
||||
import io.ebean.EbeanServer;
|
||||
import io.ebean.Database;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.event.BeanDeleteIdRequest;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
|
||||
final class DeleteIdRequest implements BeanDeleteIdRequest {
|
||||
|
||||
private final EbeanServer server;
|
||||
private final SpiEbeanServer server;
|
||||
private final Transaction transaction;
|
||||
private Class<?> beanType;
|
||||
private final Class<?> beanType;
|
||||
private Object id;
|
||||
|
||||
DeleteIdRequest(SpiEbeanServer server, Transaction transaction, Class<?> beanType, Object id) {
|
||||
@@ -24,7 +24,7 @@ final class DeleteIdRequest implements BeanDeleteIdRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EbeanServer getEbeanServer() {
|
||||
public Database database() {
|
||||
return server;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import io.ebeaninternal.server.core.SpiOrmQueryRequest;
|
||||
import io.ebeaninternal.server.deploy.*;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
@@ -149,8 +148,6 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
|
||||
private final ProfilingListener profilingListener;
|
||||
|
||||
private final WeakReference<NodeUsageListener> profilingListenerRef;
|
||||
|
||||
private final Boolean readOnly;
|
||||
|
||||
private long profileOffset;
|
||||
@@ -189,7 +186,6 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
this.objectGraphNode = query.getParentNode();
|
||||
this.profilingListener = query.getProfilingListener();
|
||||
this.autoTuneProfiling = profilingListener != null;
|
||||
this.profilingListenerRef = autoTuneProfiling ? new WeakReference<>(profilingListener) : null;
|
||||
// set the generated sql back to the query
|
||||
// so its available to the user...
|
||||
query.setGeneratedSql(queryPlan.getSql());
|
||||
@@ -673,7 +669,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
@Override
|
||||
public void profileBean(EntityBeanIntercept ebi, String prefix) {
|
||||
ObjectGraphNode node = request.loadContext().getObjectGraphNode(prefix);
|
||||
ebi.setNodeUsageCollector(new NodeUsageCollector(node, profilingListenerRef));
|
||||
ebi.setNodeUsageCollector(new NodeUsageCollector(node, profilingListener));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -644,9 +644,12 @@ final class CQueryBuilder {
|
||||
}
|
||||
|
||||
private void appendHistoryAsOfPredicate() {
|
||||
if (query.isAsOfBaseTable() && !historySupport.isStandardsBased()) {
|
||||
appendAndOrWhere();
|
||||
sb.append(historySupport.getAsOfPredicate(request.baseTableAlias()));
|
||||
if (query.isAsOfBaseTable()) {
|
||||
query.incrementAsOfTableCount();
|
||||
if (!historySupport.isStandardsBased()){
|
||||
appendAndOrWhere();
|
||||
sb.append(historySupport.getAsOfPredicate(request.baseTableAlias()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,45 +18,27 @@ final class DefaultDbSqlContext implements DbSqlContext {
|
||||
private static final String tableAliasManyPlaceHolder = "${mta}";
|
||||
|
||||
private final String columnAliasPrefix;
|
||||
|
||||
private final ArrayStack<String> tableAliasStack = new ArrayStack<>();
|
||||
|
||||
private final ArrayStack<String> joinStack = new ArrayStack<>();
|
||||
|
||||
private final ArrayStack<String> prefixStack = new ArrayStack<>();
|
||||
|
||||
private final String fromForUpdate;
|
||||
|
||||
private boolean useColumnAlias;
|
||||
|
||||
private int columnIndex;
|
||||
|
||||
private int asOfTableCount;
|
||||
private StringBuilder sb = new StringBuilder(STRING_BUILDER_INITIAL_CAPACITY);
|
||||
|
||||
/**
|
||||
* A Set used to make sure formula joins are only added once to a query.
|
||||
*/
|
||||
private HashSet<String> formulaJoins;
|
||||
|
||||
private HashSet<String> tableJoins;
|
||||
|
||||
private final SqlTreeAlias alias;
|
||||
|
||||
private String currentPrefix;
|
||||
|
||||
private List<BeanProperty> encryptedProps;
|
||||
|
||||
private List<SqlTreeJoin> extraJoins;
|
||||
|
||||
private final CQueryDraftSupport draftSupport;
|
||||
|
||||
private final CQueryHistorySupport historySupport;
|
||||
|
||||
private final boolean historyQuery;
|
||||
|
||||
/**
|
||||
* Construct for SELECT clause (with column alias settings).
|
||||
*/
|
||||
DefaultDbSqlContext(SqlTreeAlias alias, String columnAliasPrefix, CQueryHistorySupport historySupport,
|
||||
CQueryDraftSupport draftSupport, String fromForUpdate) {
|
||||
this.alias = alias;
|
||||
@@ -116,7 +98,6 @@ final class DefaultDbSqlContext implements DbSqlContext {
|
||||
if (encryptedProps == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return encryptedProps.toArray(new BeanProperty[0]);
|
||||
}
|
||||
|
||||
@@ -153,6 +134,9 @@ final class DefaultDbSqlContext implements DbSqlContext {
|
||||
String asOfView = historySupport.getAsOfView(table);
|
||||
appendTable(table, asOfView);
|
||||
if (asOfView != null) {
|
||||
if (historySupport.isStandardsBased()) {
|
||||
asOfTableCount++;
|
||||
}
|
||||
addAsOfOnClause = !historySupport.isStandardsBased();
|
||||
}
|
||||
}
|
||||
@@ -178,6 +162,7 @@ final class DefaultDbSqlContext implements DbSqlContext {
|
||||
}
|
||||
if (addAsOfOnClause) {
|
||||
sb.append(" and ").append(historySupport.getAsOfPredicate(a2));
|
||||
asOfTableCount++;
|
||||
}
|
||||
if (extraWhere != null && !extraWhere.isEmpty()) {
|
||||
sb.append(" and ");
|
||||
@@ -195,6 +180,11 @@ final class DefaultDbSqlContext implements DbSqlContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int asOfTableCount() {
|
||||
return asOfTableCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDraftQuery() {
|
||||
return draftSupport != null;
|
||||
@@ -236,7 +226,7 @@ final class DefaultDbSqlContext implements DbSqlContext {
|
||||
|
||||
@Override
|
||||
public void appendFormulaJoin(String sqlFormulaJoin, SqlJoinType joinType, String manyWhere) {
|
||||
// replace ${ta} place holder with the real table alias...
|
||||
// replace ${ta} placeholder with the real table alias...
|
||||
String tableAlias = manyWhere == null ? tableAliasStack.peek() : getTableAliasManyWhere(manyWhere);
|
||||
String converted = sqlFormulaJoin.replace(tableAliasPlaceHolder, tableAlias);
|
||||
if (formulaJoins == null) {
|
||||
@@ -250,9 +240,9 @@ final class DefaultDbSqlContext implements DbSqlContext {
|
||||
formulaJoins.add(converted);
|
||||
sb.append(" ");
|
||||
if (joinType == SqlJoinType.OUTER) {
|
||||
if ("join".equals(sqlFormulaJoin.substring(0, 4).toLowerCase())) {
|
||||
if ("join".equalsIgnoreCase(sqlFormulaJoin.substring(0, 4))) {
|
||||
// prepend left as we are in the 'many' part
|
||||
append(" left ");
|
||||
sb.append("left ");
|
||||
}
|
||||
}
|
||||
sb.append(converted);
|
||||
|
||||
@@ -432,26 +432,11 @@ final class DefaultFetchGroupQuery<T> implements SpiFetchGroupQuery<T>, SpiQuery
|
||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> order(String orderByClause) {
|
||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderBy<T> order() {
|
||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderBy<T> orderBy() {
|
||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> setOrder(OrderBy<T> orderBy) {
|
||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> setOrderBy(OrderBy<T> orderBy) {
|
||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||
|
||||
@@ -127,6 +127,7 @@ public final class SqlTreeBuilder {
|
||||
groupBy = buildGroupByClause();
|
||||
distinctOn = buildDistinctOn();
|
||||
encryptedProps = ctx.getEncryptedProps();
|
||||
query.incrementAsOfTableCount(ctx.asOfTableCount());
|
||||
}
|
||||
|
||||
boolean includeJoins = alias != null && alias.isIncludeJoins();
|
||||
|
||||
@@ -302,20 +302,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
|
||||
@Override
|
||||
public void addAsOfTableAlias(SpiQuery<?> query) {
|
||||
// if history on this bean type add it's alias
|
||||
// for each alias we add an effect date predicate
|
||||
if (desc.isHistorySupport()) {
|
||||
query.incrementAsOfTableCount();
|
||||
}
|
||||
if (lazyLoadParent != null && lazyLoadParent.isManyToManyWithHistory()) {
|
||||
query.incrementAsOfTableCount();
|
||||
}
|
||||
if (intersectionAsOfTableAlias) {
|
||||
query.incrementAsOfTableCount();
|
||||
}
|
||||
for (SqlTreeNode child : children) {
|
||||
child.addAsOfTableAlias(query);
|
||||
}
|
||||
// do nothing for non-root, handled by DbSqlContext for joins
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -58,13 +58,6 @@ final class SqlTreeNodeRoot extends SqlTreeNodeBean {
|
||||
public void addAsOfTableAlias(SpiQuery<?> query) {
|
||||
if (desc.isHistorySupport()) {
|
||||
query.setAsOfBaseTable();
|
||||
query.incrementAsOfTableCount();
|
||||
}
|
||||
if (lazyLoadParent != null && lazyLoadParent.isManyToManyWithHistory()) {
|
||||
query.incrementAsOfTableCount();
|
||||
}
|
||||
for (SqlTreeNode aChildren : children) {
|
||||
aChildren.addAsOfTableAlias(query);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -316,6 +316,11 @@ public final class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<
|
||||
asOfTableCount++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementAsOfTableCount(int increment) {
|
||||
asOfTableCount += increment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAsOfTableCount() {
|
||||
return asOfTableCount;
|
||||
@@ -1608,13 +1613,7 @@ public final class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public OrderBy<T> orderBy() {
|
||||
return order();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderBy<T> order() {
|
||||
if (orderBy == null) {
|
||||
orderBy = new OrderBy<>(this, null);
|
||||
}
|
||||
@@ -1622,13 +1621,7 @@ public final class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Query<T> orderBy(String orderByClause) {
|
||||
return order(orderByClause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> order(String orderByClause) {
|
||||
if (orderByClause == null || orderByClause.trim().isEmpty()) {
|
||||
this.orderBy = null;
|
||||
} else {
|
||||
@@ -1638,13 +1631,7 @@ public final class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Query<T> setOrderBy(OrderBy<T> orderBy) {
|
||||
return setOrder(orderBy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> setOrder(OrderBy<T> orderBy) {
|
||||
this.orderBy = orderBy;
|
||||
if (orderBy != null) {
|
||||
orderBy.setQuery(this);
|
||||
|
||||
+1
-10
@@ -378,19 +378,12 @@ final class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEve
|
||||
/**
|
||||
* Flush any queued persist requests.
|
||||
* <p>
|
||||
* This is general will result in a number of batched PreparedStatements
|
||||
* executing.
|
||||
* </p>
|
||||
* This is general will result in a number of batched PreparedStatements executing.
|
||||
*/
|
||||
@Override
|
||||
public void flush() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushBatch() {
|
||||
flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the persistence context associated with this transaction.
|
||||
*/
|
||||
@@ -405,7 +398,6 @@ final class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEve
|
||||
* This could be considered similar to EJB3 Extended PersistanceContext. In
|
||||
* that you get the PersistanceContext from a transaction, hold onto it, and
|
||||
* then set it back later to a second transaction.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public void setPersistenceContext(SpiPersistenceContext context) {
|
||||
@@ -503,7 +495,6 @@ final class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEve
|
||||
* <p>
|
||||
* This leaves the transaction active and expects another commit
|
||||
* to occur later (which closes the underlying connection etc).
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public void commitAndContinue() {
|
||||
|
||||
@@ -758,11 +758,6 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
internalBatchFlush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void flushBatch() {
|
||||
flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the JDBC batch and execute derived relationship statements if necessary.
|
||||
*/
|
||||
|
||||
+4
-14
@@ -27,7 +27,7 @@ public final class JtaTransactionManager implements ExternalTransactionManager {
|
||||
private TransactionScopeManager scope;
|
||||
|
||||
/**
|
||||
* Instantiates a new spring aware transaction scope manager.
|
||||
* Instantiates a new JTA transaction manager.
|
||||
*/
|
||||
public JtaTransactionManager() {
|
||||
}
|
||||
@@ -37,10 +37,8 @@ public final class JtaTransactionManager implements ExternalTransactionManager {
|
||||
*/
|
||||
@Override
|
||||
public void setTransactionManager(Object txnMgr) {
|
||||
|
||||
// RB: At this stage not exposing TransactionManager to
|
||||
// the public API and hence the Object type and casting here
|
||||
|
||||
this.transactionManager = (TransactionManager) txnMgr;
|
||||
this.scope = transactionManager.scope();
|
||||
}
|
||||
@@ -72,16 +70,13 @@ public final class JtaTransactionManager implements ExternalTransactionManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for a current Spring managed transaction and wraps/returns that as a Ebean transaction.
|
||||
* Looks for a current JTA managed transaction and wraps/returns that as an Ebean transaction.
|
||||
* <p>
|
||||
* Returns null if there is no current spring transaction (lazy loading outside a spring txn etc).
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public Object getCurrentTransaction() {
|
||||
|
||||
TransactionSynchronizationRegistry syncRegistry = getSyncRegistry();
|
||||
|
||||
SpiTransaction t = (SpiTransaction) syncRegistry.getResource(EBEAN_TXN_RESOURCE);
|
||||
if (t != null) {
|
||||
// we have already seen this transaction
|
||||
@@ -122,14 +117,10 @@ public final class JtaTransactionManager implements ExternalTransactionManager {
|
||||
return newTrans;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a listener to register with JTA to enable Ebean to be
|
||||
* notified when transactions commit and rollback.
|
||||
* Create a listener to register with JTA to enable Ebean to be notified when transactions commit and rollback.
|
||||
* <p>
|
||||
* This is used by Ebean to notify it's appropriate listeners and maintain it's server
|
||||
* cache etc.
|
||||
* </p>
|
||||
* This is used by Ebean to notify its appropriate listeners and maintain its server cache etc.
|
||||
*/
|
||||
private JtaTxnListener createJtaTxnListener(SpiTransaction t) {
|
||||
return new JtaTxnListener(transactionManager, t);
|
||||
@@ -169,7 +160,6 @@ public final class JtaTransactionManager implements ExternalTransactionManager {
|
||||
* <p>
|
||||
* When Ebean is notified (of the commit/rollback) it can then manage its
|
||||
* cache, notify BeanPersistListeners etc.
|
||||
* </p>
|
||||
*/
|
||||
private static class JtaTxnListener implements Synchronization {
|
||||
|
||||
|
||||
@@ -283,10 +283,6 @@ final class NoTransaction implements SpiTransaction {
|
||||
public void flush() throws PersistenceException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushBatch() throws PersistenceException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection connection() {
|
||||
return null;
|
||||
|
||||
@@ -3,7 +3,7 @@ package io.ebeaninternal.server.core;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.datasource.DataSourceAlert;
|
||||
import io.ebean.datasource.DataSourceConfig;
|
||||
import io.ebean.datasource.pool.ConnectionPool;
|
||||
import io.ebean.datasource.DataSourcePool;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
@@ -137,7 +137,7 @@ public class InitDataSourceTest {
|
||||
config.getDataSourceConfig().setUrl("jdbc:h2:mem:dsTestOnline");
|
||||
config.getDataSourceConfig().setDriver("org.h2.Driver");
|
||||
InitDataSource.init(config);
|
||||
ConnectionPool pool = (ConnectionPool) config.getDataSource();
|
||||
DataSourcePool pool = (DataSourcePool) config.getDataSource();
|
||||
assertThat(pool.isDataSourceUp()).isTrue();
|
||||
pool.shutdown();
|
||||
}
|
||||
@@ -174,7 +174,7 @@ public class InitDataSourceTest {
|
||||
config.getDataSourceConfig().setAlert(alert);
|
||||
config.setDatabasePlatformName("h2");
|
||||
InitDataSource.init(config);
|
||||
ConnectionPool pool = (ConnectionPool) config.getDataSource();
|
||||
DataSourcePool pool = (DataSourcePool) config.getDataSource();
|
||||
assertThat(pool).isNotNull();
|
||||
// make some additional tests with the pool
|
||||
assertThat(pool.isDataSourceUp()).isFalse();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.ebeaninternal.server.expression;
|
||||
|
||||
import io.ebean.EbeanServer;
|
||||
import io.ebean.Database;
|
||||
import io.ebean.Query;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.event.BeanQueryRequest;
|
||||
@@ -62,7 +62,7 @@ public abstract class BaseExpressionTest extends BaseTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EbeanServer getEbeanServer() {
|
||||
public Database database() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user