-
+
From 7074b0de710a4af2b771a4f806182fec28c4917e Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Mon, 19 Dec 2016 16:40:00 +1300
Subject: [PATCH 044/116] No effective change - use enhanced for
---
.../ebean/spring/txn/SpringAwareJdbcTransactionManager.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/main/java/io/ebean/spring/txn/SpringAwareJdbcTransactionManager.java b/src/main/java/io/ebean/spring/txn/SpringAwareJdbcTransactionManager.java
index ece4df792..c7b1db312 100644
--- a/src/main/java/io/ebean/spring/txn/SpringAwareJdbcTransactionManager.java
+++ b/src/main/java/io/ebean/spring/txn/SpringAwareJdbcTransactionManager.java
@@ -136,9 +136,9 @@ public class SpringAwareJdbcTransactionManager implements ExternalTransactionMan
List synchronizations = TransactionSynchronizationManager.getSynchronizations();
if (synchronizations != null) {
// search for our specific listener
- for (int i = 0; i < synchronizations.size(); i++) {
- if (synchronizations.get(i) instanceof SpringTxnListener) {
- return (SpringTxnListener) synchronizations.get(i);
+ for (TransactionSynchronization synchronization : synchronizations) {
+ if (synchronization instanceof SpringTxnListener) {
+ return (SpringTxnListener) synchronization;
}
}
}
From 23c278d878160617860b225d6b28e1388c0e1bc4 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Wed, 21 Dec 2016 20:44:47 +1300
Subject: [PATCH 045/116] pom dependencies - ebean and slf4j-api as provided
(versions expected to be controlled externally)
---
pom.xml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/pom.xml b/pom.xml
index 818e425df..0fa0f500f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,12 +31,14 @@
org.slf4j
slf4j-api
[1.7,)
+ provided
io.ebean
ebean
[10,)
+ provided
From 83d84f607986815f89466ed75c3a0b12708be5b7 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Wed, 21 Dec 2016 20:53:33 +1300
Subject: [PATCH 046/116] #14 - Remove agent loading feature for spring boot as
it has been moved to ebean-spring-agent
---
pom.xml | 89 +++----------------
.../boot/EbeanAgentAutoConfiguration.java | 69 --------------
src/main/resources/META-INF/spring.factories | 2 -
.../boot/EbeanAgentAutoConfigurationTest.java | 35 --------
src/test/java/org/unenhanced/Boondoggle.java | 11 ---
src/test/java/org/unenhanced/Wotsit.java | 11 ---
6 files changed, 11 insertions(+), 206 deletions(-)
delete mode 100644 src/main/java/io/ebean/spring/boot/EbeanAgentAutoConfiguration.java
delete mode 100644 src/main/resources/META-INF/spring.factories
delete mode 100644 src/test/java/io/ebean/spring/boot/EbeanAgentAutoConfigurationTest.java
delete mode 100644 src/test/java/org/unenhanced/Boondoggle.java
delete mode 100644 src/test/java/org/unenhanced/Wotsit.java
diff --git a/pom.xml b/pom.xml
index 0fa0f500f..5baf9772b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@
org.slf4j
slf4j-api
- [1.7,)
+ 1.7.21
provided
@@ -41,22 +41,6 @@
provided
-
-
- io.ebean
- ebean-agent
- [10,)
- runtime
- true
-
-
-
- org.avaje
- avaje-agentloader
- 2.1.2
- true
-
-
org.springframework
@@ -71,13 +55,6 @@
-
- org.springframework.boot
- spring-boot-autoconfigure
- ${spring.boot.version}
- provided
-
-
org.springframework
@@ -117,64 +94,20 @@
+
- io.ebean
- ebean-maven-plugin
- 10.1.1
-
-
- main
- process-test-classes
-
- target/test-classes
- org.example.**
- debug=1
-
-
- enhance
-
-
-
-
-
- maven-surefire-plugin
- 2.18.1
+ io.repaint.maven
+ tiles-maven-plugin
+ 2.8
+ true
-
- false
+
+ io.ebean.tile:enhancement:2.1
+
-
-
-
-
-
- org.eclipse.m2e
- lifecycle-mapping
- 1.0.0
-
-
-
-
-
- io.ebean
- ebean-maven-plugin
- [1,)
-
- enhance
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/src/main/java/io/ebean/spring/boot/EbeanAgentAutoConfiguration.java b/src/main/java/io/ebean/spring/boot/EbeanAgentAutoConfiguration.java
deleted file mode 100644
index d9970a77a..000000000
--- a/src/main/java/io/ebean/spring/boot/EbeanAgentAutoConfiguration.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package io.ebean.spring.boot;
-
-import org.avaje.agentloader.AgentLoader;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.boot.autoconfigure.AutoConfigureOrder;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.Ordered;
-import org.springframework.core.PriorityOrdered;
-
-
-/**
- * Loads the Ebean enhancement agent early in the Spring Boot startup process,
- * if it is present on the classpath.
- *
- * Note that using this mechanism is only recommended for development;
- * production applications should ideally be enhanced at build time, or at least
- * load the agent via the javaagent JVM option. When the agent is
- * loaded at runtime via this class, any entity classes that have already been
- * loaded won't be enhanced and will fail to work correctly.
- *
- * For unit tests and similar cases where Spring Boot auto-configuration may not
- * be active, loading of the agent can be triggered manually via
- * {@link #enable()}.
- */
-@Configuration
-@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
-@ConditionalOnClass(AgentLoader.class)
-public class EbeanAgentAutoConfiguration implements BeanFactoryPostProcessor, PriorityOrdered {
-
- public EbeanAgentAutoConfiguration() {
- load(); // Spring has already evaluated the @ConditionalOnClass
- }
-
- @Override
- public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
- // We're not actually doing anything with the BeanFactory, but implementing
- // BeanFactoryPostProcessor ensures we get instantiated early, ideally
- // before anybody has a chance to load any entity classes we want to
- // enhance.
- }
-
- @Override
- public int getOrder() {
- return Ordered.HIGHEST_PRECEDENCE;
- }
-
- private static void load() {
- AgentLoader.loadAgentFromClasspath("ebean-agent", "debug=1");
- }
-
- /**
- * Loads the Ebean agent if the agent-loader and the agent itself are present
- * on the classpath, or does nothing otherwise.
- *
- * Do not call this method from a static initializer as this can lead to a JVM
- * deadlock (the agent attach thread will attempt to acquire the class loader
- * lock, which is held during static initialization).
- */
- public static void enable() {
- try {
- load();
- } catch (NoClassDefFoundError e) {
- /* ignored */
- }
- }
-}
diff --git a/src/main/resources/META-INF/spring.factories b/src/main/resources/META-INF/spring.factories
deleted file mode 100644
index d4fedf3b0..000000000
--- a/src/main/resources/META-INF/spring.factories
+++ /dev/null
@@ -1,2 +0,0 @@
-org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-io.ebean.spring.boot.EbeanAgentAutoConfiguration
diff --git a/src/test/java/io/ebean/spring/boot/EbeanAgentAutoConfigurationTest.java b/src/test/java/io/ebean/spring/boot/EbeanAgentAutoConfigurationTest.java
deleted file mode 100644
index bbd7bc81e..000000000
--- a/src/test/java/io/ebean/spring/boot/EbeanAgentAutoConfigurationTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package io.ebean.spring.boot;
-
-import io.ebean.bean.EntityBean;
-import org.junit.Test;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
-import org.unenhanced.Boondoggle;
-import org.unenhanced.Wotsit;
-import static org.assertj.core.api.StrictAssertions.assertThat;
-
-@SpringBootTest(webEnvironment=WebEnvironment.NONE)
-public class EbeanAgentAutoConfigurationTest extends AbstractJUnit4SpringContextTests {
-
- static {
- // Validate our test setup. Agent should not be loaded yet, so 'Boondoggle'
- // should have been enhanced neither at build time nor at load time.
- assertThat(EntityBean.class.isAssignableFrom(Boondoggle.class)).isFalse();
- }
-
- @Configuration
- @EnableAutoConfiguration
- public static class Config {
- /* no beans needed for this test */
- }
-
- @Test
- public void testAgentIsWorking() {
- // Wotsit is outside of the org.example package that's being enhanced
- // at build time, so should be picked up by the agent only.
- assertThat(EntityBean.class.isAssignableFrom(Wotsit.class)).isTrue();
- }
-}
diff --git a/src/test/java/org/unenhanced/Boondoggle.java b/src/test/java/org/unenhanced/Boondoggle.java
deleted file mode 100644
index 0d23f258d..000000000
--- a/src/test/java/org/unenhanced/Boondoggle.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.unenhanced;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-
-// Not in org.example, i.e. not enhanced at build time
-@Entity
-public class Boondoggle {
- @Id
- public String name;
-}
diff --git a/src/test/java/org/unenhanced/Wotsit.java b/src/test/java/org/unenhanced/Wotsit.java
deleted file mode 100644
index e2e723caf..000000000
--- a/src/test/java/org/unenhanced/Wotsit.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.unenhanced;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-
-// Not in org.example, i.e. not enhanced at build time
-@Entity
-public class Wotsit {
- @Id
- public String name;
-}
From 16aa4cacebe36deafc17532341c3b880d7fb609e Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Wed, 21 Dec 2016 20:57:28 +1300
Subject: [PATCH 047/116] #15 - Rename artifact to ebean-spring-txn ... (as
this is specific and only for integration with spring transactions)
---
pom.xml | 4 ++--
...actionManager.java => SpringJdbcTransactionManager.java} | 6 +++---
src/test/resources/default-ebean-server.xml | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
rename src/main/java/io/ebean/spring/txn/{SpringAwareJdbcTransactionManager.java => SpringJdbcTransactionManager.java} (97%)
diff --git a/pom.xml b/pom.xml
index 5baf9772b..edcebe33c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,11 +9,11 @@
io.ebean
- ebean-spring
+ ebean-spring-txn
ebean-spring
10.1.1-SNAPSHOT
jar
- Ebean support for Spring and Spring Boot
+ Ebean support for Spring transactions
4.3.4.RELEASE
diff --git a/src/main/java/io/ebean/spring/txn/SpringAwareJdbcTransactionManager.java b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
similarity index 97%
rename from src/main/java/io/ebean/spring/txn/SpringAwareJdbcTransactionManager.java
rename to src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
index c7b1db312..f95336a64 100644
--- a/src/main/java/io/ebean/spring/txn/SpringAwareJdbcTransactionManager.java
+++ b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
@@ -43,9 +43,9 @@ import java.util.List;
* @since 18.05.2009
* @author E Mc Greal
*/
-public class SpringAwareJdbcTransactionManager implements ExternalTransactionManager {
+public class SpringJdbcTransactionManager implements ExternalTransactionManager {
- private static final Logger log = LoggerFactory.getLogger(SpringAwareJdbcTransactionManager.class);
+ private static final Logger log = LoggerFactory.getLogger(SpringJdbcTransactionManager.class);
/**
* The data source.
@@ -65,7 +65,7 @@ public class SpringAwareJdbcTransactionManager implements ExternalTransactionMan
/**
* Instantiates a new spring aware transaction scope manager.
*/
- public SpringAwareJdbcTransactionManager() {
+ public SpringJdbcTransactionManager() {
}
/**
diff --git a/src/test/resources/default-ebean-server.xml b/src/test/resources/default-ebean-server.xml
index bdf75a246..44da26196 100644
--- a/src/test/resources/default-ebean-server.xml
+++ b/src/test/resources/default-ebean-server.xml
@@ -6,7 +6,7 @@
-
+
From 052632239ef7fa2cc66c2cfe053ee031021606b4 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Wed, 21 Dec 2016 20:58:28 +1300
Subject: [PATCH 048/116] pom - update name
---
pom.xml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index edcebe33c..b85482ee2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,8 +10,9 @@
io.ebean
ebean-spring-txn
- ebean-spring
10.1.1-SNAPSHOT
+
+ ebean-spring-txn
jar
Ebean support for Spring transactions
From e57a074b68777070c01bbe8b49f8a839643a2a90 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Wed, 21 Dec 2016 20:59:00 +1300
Subject: [PATCH 049/116] [maven-release-plugin] prepare release
ebean-spring-txn-10.1.1
---
pom.xml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index b85482ee2..4d66c5ace 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 10.1.1-SNAPSHOT
+ 10.1.1
ebean-spring-txn
jar
@@ -25,6 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring.git
+ ebean-spring-txn-10.1.1
From 6360d5fe1c369edef7481e90f737626f46872180 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Wed, 21 Dec 2016 20:59:11 +1300
Subject: [PATCH 050/116] [maven-release-plugin] prepare for next development
iteration
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 4d66c5ace..5c49e5251 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 10.1.1
+ 10.1.2-SNAPSHOT
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring.git
- ebean-spring-txn-10.1.1
+ HEAD
From 844df4d5c96826a33c05e775e3329478319ba267 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Wed, 21 Dec 2016 21:04:47 +1300
Subject: [PATCH 051/116] Update scm due to rename to ebean-spring-txn
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 5c49e5251..d2208ebe3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
http://ebean-orm.github.io/
- scm:git:git@github.com:ebean-orm/ebean-spring.git
+ scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
HEAD
From 6bcc8eb0f26404a0824b828efa63a05603370d53 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Wed, 21 Dec 2016 21:11:00 +1300
Subject: [PATCH 052/116] Update Readme
---
README.md | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index e9f3b4c45..ebead78bb 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,14 @@
-avaje-ebeanorm-spring
+ebean-spring-txn
=====================
-Spring integration with EbeanORM
\ No newline at end of file
+Integration with Spring managed transactions.
+
+This project provides an Ebean `ExternalTransactionManager` specifically
+to integrate with Springs JDBC Transaction manager.
+
+You can use Ebean in Spring/Spring Boot *without* this and that case Ebean
+manages the Transactions itself. With Ebean managing the transactions there
+are some benefits with more control over JDBC batch, getGeneratedKeys
+and a simpler abstraction (as Spring transactions is designed to manage
+multiple resources such as JDBC Transactions and JPA EntityManager and Ebean
+only needs to manage JDBC Transactions).
\ No newline at end of file
From dca824b431a2784c9bc4cbc546f9fc64b7492c32 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Tue, 30 Jan 2018 23:52:40 +1300
Subject: [PATCH 053/116] #16 - Bump to support Ebean 11.5.1+
---
pom.xml | 36 ++++++++++++++-----
.../txn/SpringJdbcTransactionManager.java | 24 +++++++------
.../java/org/example/UserServiceImpl.java | 21 ++++-------
src/test/resources/logback-test.xml | 32 +++++++++++++++++
4 files changed, 80 insertions(+), 33 deletions(-)
create mode 100644 src/test/resources/logback-test.xml
diff --git a/pom.xml b/pom.xml
index d2208ebe3..85a2d7f39 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 10.1.2-SNAPSHOT
+ 11.5.1-SNAPSHOT
ebean-spring-txn
jar
@@ -32,14 +32,14 @@
org.slf4j
slf4j-api
- 1.7.21
+ 1.7.25
provided
io.ebean
ebean
- [10,)
+ 11.5.1
provided
@@ -79,10 +79,30 @@
- org.avaje.composite
- avaje-composite-testing-ebean
- 4.1
- pom
+ junit
+ junit
+ 4.12
+ test
+
+
+
+ org.assertj
+ assertj-core
+ 3.1.0
+ test
+
+
+
+ com.h2database
+ h2
+ 1.4.196
+ test
+
+
+
+ ch.qos.logback
+ logback-classic
+ 1.2.3
test
@@ -104,7 +124,7 @@
true
- io.ebean.tile:enhancement:2.1
+ io.ebean.tile:enhancement:5.2
diff --git a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
index f95336a64..9bf3ce707 100644
--- a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
+++ b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
@@ -19,10 +19,15 @@
*/
package io.ebean.spring.txn;
+import io.ebean.TxScope;
import io.ebean.config.ExternalTransactionManager;
+import io.ebeaninternal.api.ScopeTrans;
+import io.ebeaninternal.api.ScopedTransaction;
import io.ebeaninternal.api.SpiTransaction;
+import io.ebeaninternal.server.transaction.DefaultTransactionScopeManager;
import io.ebeaninternal.server.transaction.DefaultTransactionThreadLocal;
import io.ebeaninternal.server.transaction.TransactionManager;
+import io.ebeaninternal.server.transaction.TransactionScopeManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.datasource.ConnectionHolder;
@@ -57,10 +62,7 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
*/
private TransactionManager transactionManager;
- /**
- * The EbeanServer name.
- */
- private String serverName;
+ private TransactionScopeManager scope;
/**
* Instantiates a new spring aware transaction scope manager.
@@ -76,10 +78,9 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
// RB: At this stage not exposing TransactionManager to
// the public API and hence the Object type and casting here
-
this.transactionManager = (TransactionManager) txnMgr;
this.dataSource = transactionManager.getDataSource();
- this.serverName = transactionManager.getServerName();
+ this.scope = new DefaultTransactionScopeManager(transactionManager);
}
/**
@@ -96,7 +97,7 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
if (holder == null || !holder.isSynchronizedWithTransaction()) {
// no current Spring transaction
- SpiTransaction currentEbeanTransaction = DefaultTransactionThreadLocal.get(serverName);
+ SpiTransaction currentEbeanTransaction = scope.get();
if (currentEbeanTransaction != null) { // this is unexpected
log.warn("No current Spring transaction BUT using current Ebean one {}", currentEbeanTransaction.getId());
} else {
@@ -118,9 +119,10 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
springTxnLister = createSpringTxnListener(newTrans);
TransactionSynchronizationManager.registerSynchronization(springTxnLister);
- // also put in Ebean ThreadLocal
- DefaultTransactionThreadLocal.set(serverName, newTrans);
- return newTrans;
+ ScopedTransaction scopedTxn = new ScopedTransaction(scope);
+ scopedTxn.push(new ScopeTrans(true, false, newTrans, TxScope.required()));
+ scope.set(scopedTxn);
+ return scopedTxn;
}
}
@@ -185,7 +187,7 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
/**
* Return the associated Ebean wrapped transaction.
*/
- public SpringJdbcTransaction getTransaction() {
+ SpringJdbcTransaction getTransaction() {
return transaction;
}
diff --git a/src/test/java/org/example/UserServiceImpl.java b/src/test/java/org/example/UserServiceImpl.java
index b828010a6..43448b8ed 100644
--- a/src/test/java/org/example/UserServiceImpl.java
+++ b/src/test/java/org/example/UserServiceImpl.java
@@ -21,7 +21,6 @@
package org.example;
import io.ebean.Transaction;
-import io.ebean.PersistBatch;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@@ -43,10 +42,7 @@ public class UserServiceImpl implements UserService {
@Autowired
private EbeanServer ebeanServer;
- /* (non-Javadoc)
- * @see org.spring.modules.ebean.UserService#save(org.spring.modules.ebean.User)
- */
- @Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor=Throwable.class)
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor=Throwable.class)
public void save(User user) {
ebeanServer.save(user);
}
@@ -56,12 +52,11 @@ public class UserServiceImpl implements UserService {
return ebeanServer.find(User.class, id);
}
+ @Transactional(propagation = Propagation.REQUIRED)
+ public void batchInsert() {
- @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
- public void batchInsert(){
-
- List users = new ArrayList();
- for(int i=0 ;i<5;i++){
+ List users = new ArrayList<>();
+ for(int i=0 ;i<25;i++){
User user = new User();
user.setName("user"+i);
users.add(user);
@@ -69,11 +64,9 @@ public class UserServiceImpl implements UserService {
System.out.println("---------before batch-------");
- Transaction tx = ebeanServer.beginTransaction();
- tx.setBatch(PersistBatch.NONE);
- tx.setBatchOnCascade(PersistBatch.ALL);
+ Transaction tx = ebeanServer.currentTransaction();
tx.setBatchSize(20);
- ebeanServer.saveAll(users);//
+ ebeanServer.saveAll(users);
System.out.println("---------after batch-------");
}
diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml
new file mode 100644
index 000000000..e096c77e4
--- /dev/null
+++ b/src/test/resources/logback-test.xml
@@ -0,0 +1,32 @@
+
+
+
+ TRACE
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From 211087f6366fd88072fcff2e4da20a233e5f5de1 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Tue, 30 Jan 2018 23:53:10 +1300
Subject: [PATCH 054/116] [maven-release-plugin] prepare release
ebean-spring-txn-11.5.1
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 85a2d7f39..fc6be8eae 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 11.5.1-SNAPSHOT
+ 11.5.1
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- HEAD
+ ebean-spring-txn-11.5.1
From cbdc6e09aa44cde2864703eabece04c57974aa4c Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Tue, 30 Jan 2018 23:53:23 +1300
Subject: [PATCH 055/116] [maven-release-plugin] prepare for next development
iteration
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index fc6be8eae..5a6dc8e1a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 11.5.1
+ 11.5.2-SNAPSHOT
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- ebean-spring-txn-11.5.1
+ HEAD
From a272fb4e02f4a71c9b8a23f0edba0759f95aca69 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Sat, 3 Feb 2018 00:04:22 +1300
Subject: [PATCH 056/116] #17 - Refactor to use the better internals in Ebean
11.10.1
---
pom.xml | 4 +-
.../txn/SpringJdbcTransactionManager.java | 39 ++-----------------
2 files changed, 5 insertions(+), 38 deletions(-)
diff --git a/pom.xml b/pom.xml
index 5a6dc8e1a..af5661390 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 11.5.2-SNAPSHOT
+ 11.10.1-SNAPSHOT
ebean-spring-txn
jar
@@ -39,7 +39,7 @@
io.ebean
ebean
- 11.5.1
+ 11.10.1
provided
diff --git a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
index 9bf3ce707..09c3ecfc4 100644
--- a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
+++ b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
@@ -1,33 +1,9 @@
-/**
- * Copyright (C) 2009 the original author or authors
- *
- * This file is part of Ebean.
- *
- * Ebean is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * Ebean is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Ebean; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
package io.ebean.spring.txn;
import io.ebean.TxScope;
import io.ebean.config.ExternalTransactionManager;
-import io.ebeaninternal.api.ScopeTrans;
-import io.ebeaninternal.api.ScopedTransaction;
import io.ebeaninternal.api.SpiTransaction;
-import io.ebeaninternal.server.transaction.DefaultTransactionScopeManager;
-import io.ebeaninternal.server.transaction.DefaultTransactionThreadLocal;
import io.ebeaninternal.server.transaction.TransactionManager;
-import io.ebeaninternal.server.transaction.TransactionScopeManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.datasource.ConnectionHolder;
@@ -62,8 +38,6 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
*/
private TransactionManager transactionManager;
- private TransactionScopeManager scope;
-
/**
* Instantiates a new spring aware transaction scope manager.
*/
@@ -80,7 +54,6 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
// the public API and hence the Object type and casting here
this.transactionManager = (TransactionManager) txnMgr;
this.dataSource = transactionManager.getDataSource();
- this.scope = new DefaultTransactionScopeManager(transactionManager);
}
/**
@@ -97,7 +70,7 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
if (holder == null || !holder.isSynchronizedWithTransaction()) {
// no current Spring transaction
- SpiTransaction currentEbeanTransaction = scope.get();
+ SpiTransaction currentEbeanTransaction = transactionManager.get();
if (currentEbeanTransaction != null) { // this is unexpected
log.warn("No current Spring transaction BUT using current Ebean one {}", currentEbeanTransaction.getId());
} else {
@@ -119,10 +92,7 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
springTxnLister = createSpringTxnListener(newTrans);
TransactionSynchronizationManager.registerSynchronization(springTxnLister);
- ScopedTransaction scopedTxn = new ScopedTransaction(scope);
- scopedTxn.push(new ScopeTrans(true, false, newTrans, TxScope.required()));
- scope.set(scopedTxn);
- return scopedTxn;
+ return transactionManager.externalBeginTransaction(newTrans, TxScope.required());
}
}
@@ -176,12 +146,9 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
private final SpringJdbcTransaction transaction;
- private final String serverName;
-
private SpringTxnListener(TransactionManager transactionManager, SpringJdbcTransaction t) {
this.transactionManager = transactionManager;
this.transaction = t;
- this.serverName = transactionManager.getServerName();
}
/**
@@ -222,7 +189,7 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
}
// Remove this transaction object as it is completed
- DefaultTransactionThreadLocal.replace(serverName, null);
+ transactionManager.externalRemoveTransaction();
}
}
}
From 0e852f5bb5ddd4ba95a2a2d29b9c9511dbb6d638 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Sat, 3 Feb 2018 00:04:59 +1300
Subject: [PATCH 057/116] [maven-release-plugin] prepare release
ebean-spring-txn-11.10.1
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index af5661390..ab59c3d68 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 11.10.1-SNAPSHOT
+ 11.10.1
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- HEAD
+ ebean-spring-txn-11.10.1
From 206dec1bf8ce0343723355c523f7bbb344b172c6 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Sat, 3 Feb 2018 00:05:12 +1300
Subject: [PATCH 058/116] [maven-release-plugin] prepare for next development
iteration
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index ab59c3d68..b997bb5a2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 11.10.1
+ 11.10.2-SNAPSHOT
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- ebean-spring-txn-11.10.1
+ HEAD
From 0807569ee26447be40bad471e465461eeeb2bb76 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Sat, 3 Feb 2018 00:14:00 +1300
Subject: [PATCH 059/116] Update readme
---
README.md | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/README.md b/README.md
index ebead78bb..617ad1433 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,21 @@ Integration with Spring managed transactions.
This project provides an Ebean `ExternalTransactionManager` specifically
to integrate with Springs JDBC Transaction manager.
+## To use
+
+```java
+ServerConfig serverConfig = new ServerConfig();
+
+// set SpringJdbcTransactionManager ... as the external transaction manager
+serverConfig.setExternalTransactionManager(new SpringJdbcTransactionManager());
+
+...
+EbeanServer server = EbeanServerFactory.create(serverConfig);
+
+```
+
+## Notes
+
You can use Ebean in Spring/Spring Boot *without* this and that case Ebean
manages the Transactions itself. With Ebean managing the transactions there
are some benefits with more control over JDBC batch, getGeneratedKeys
From 2f66e07c25286cf4c09316379cb2b2722e8ef226 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Fri, 9 Feb 2018 22:20:57 +1300
Subject: [PATCH 060/116] Add test for
https://github.com/ebean-orm/ebean/issues/1254
---
.../org/example/EbeanSpringModuleTest.java | 13 ++++++++
src/test/java/org/example/UserService.java | 30 ++++---------------
.../java/org/example/UserServiceImpl.java | 8 +++++
3 files changed, 27 insertions(+), 24 deletions(-)
diff --git a/src/test/java/org/example/EbeanSpringModuleTest.java b/src/test/java/org/example/EbeanSpringModuleTest.java
index a17452005..54b1485af 100644
--- a/src/test/java/org/example/EbeanSpringModuleTest.java
+++ b/src/test/java/org/example/EbeanSpringModuleTest.java
@@ -83,6 +83,19 @@ public class EbeanSpringModuleTest {
logger.info("Found User with OID = 1");
}
+ @Test
+ public void testNonTransactional() {
+ userService.nonTransactional();
+ logger.info("nonTransactional done");
+ }
+
+ @Test
+ public void testFindNonTransactional() {
+ logger.info("Finding User with OID = 1 ...");
+ User user = userService.find(1);
+ logger.info("nonTransactional find " + user);
+ }
+
/**
* Return the user service.
*/
diff --git a/src/test/java/org/example/UserService.java b/src/test/java/org/example/UserService.java
index c4e7301c9..33c037a54 100644
--- a/src/test/java/org/example/UserService.java
+++ b/src/test/java/org/example/UserService.java
@@ -1,35 +1,17 @@
-/**
- * Copyright (C) 2009 the original author or authors
- *
- * This file is part of Ebean.
- *
- * Ebean is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * Ebean is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Ebean; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
package org.example;
/**
* The Interface UserService.
- * @since 18.05.2009
- * @author E Mc Greal
*/
public interface UserService {
- void save(User user);
+ void save(User user);
User find(long id);
- void batchInsert();
+ User findNoCurrentTransaction(long id);
+
+ void nonTransactional();
+
+ void batchInsert();
}
diff --git a/src/test/java/org/example/UserServiceImpl.java b/src/test/java/org/example/UserServiceImpl.java
index 43448b8ed..ccd6764ea 100644
--- a/src/test/java/org/example/UserServiceImpl.java
+++ b/src/test/java/org/example/UserServiceImpl.java
@@ -52,6 +52,14 @@ public class UserServiceImpl implements UserService {
return ebeanServer.find(User.class, id);
}
+ public void nonTransactional() {
+ ebeanServer.currentTransaction();
+ }
+
+ public User findNoCurrentTransaction(long id) {
+ return ebeanServer.find(User.class, id);
+ }
+
@Transactional(propagation = Propagation.REQUIRED)
public void batchInsert() {
From c2ddc705655531380c5374e572d471e474b06073 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Fri, 9 Feb 2018 23:05:27 +1300
Subject: [PATCH 061/116] #18 - SpringJdbcTransactionManager inifinite
recursion (Ebean #1254)
---
pom.xml | 2 +-
.../io/ebean/spring/txn/SpringJdbcTransactionManager.java | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index b997bb5a2..02a6badb0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,7 +39,7 @@
io.ebean
ebean
- 11.10.1
+ 11.10.3-SNAPSHOT
provided
diff --git a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
index 09c3ecfc4..30dd6ae88 100644
--- a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
+++ b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
@@ -70,8 +70,8 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
if (holder == null || !holder.isSynchronizedWithTransaction()) {
// no current Spring transaction
- SpiTransaction currentEbeanTransaction = transactionManager.get();
- if (currentEbeanTransaction != null) { // this is unexpected
+ SpiTransaction currentEbeanTransaction = transactionManager.getInScope();
+ if (currentEbeanTransaction != null && currentEbeanTransaction.isActive()) { // this is unexpected
log.warn("No current Spring transaction BUT using current Ebean one {}", currentEbeanTransaction.getId());
} else {
log.trace("No current Spring transaction");
From 3ee2410a79a586cec131a4a10a5ee4e3ca83f913 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Fri, 9 Feb 2018 23:46:38 +1300
Subject: [PATCH 062/116] #18 - SpringJdbcTransactionManager inifinite
recursion (Ebean #1254)
Update pom ebean version
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 02a6badb0..23b7ff0e5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,7 +39,7 @@
io.ebean
ebean
- 11.10.3-SNAPSHOT
+ 11.10.3
provided
From 49d724ad657b848d3abbd624742a84f36deeeff6 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Fri, 9 Feb 2018 23:48:01 +1300
Subject: [PATCH 063/116] Bump pom version to align with Ebean version
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 23b7ff0e5..65a275d4b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 11.10.2-SNAPSHOT
+ 11.10.3-SNAPSHOT
ebean-spring-txn
jar
From c61da5b0e5cc7bfdac7649855fd86992fb98f6d7 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Fri, 9 Feb 2018 23:48:50 +1300
Subject: [PATCH 064/116] [maven-release-plugin] prepare release
ebean-spring-txn-11.10.3
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 65a275d4b..a5e24560e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 11.10.3-SNAPSHOT
+ 11.10.3
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- HEAD
+ ebean-spring-txn-11.10.3
From fa73b7791fb2eb13ea67460a63b5209bb1febea1 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Fri, 9 Feb 2018 23:49:03 +1300
Subject: [PATCH 065/116] [maven-release-plugin] prepare for next development
iteration
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index a5e24560e..6385b363c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 11.10.3
+ 11.10.4-SNAPSHOT
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- ebean-spring-txn-11.10.3
+ HEAD
From db816594c5bc8448f6ea9374b55b64faec2314b9 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Fri, 23 Feb 2018 10:50:51 +1300
Subject: [PATCH 066/116] No effective change - tidy tests
---
src/test/java/org/example/Account.java | 26 ----------------
.../org/example/EbeanServerFactoryBean.java | 19 ------------
.../org/example/EbeanSpringModuleTest.java | 28 ++++-------------
src/test/java/org/example/Role.java | 25 ---------------
src/test/java/org/example/User.java | 31 ++++---------------
.../java/org/example/UserServiceImpl.java | 20 ------------
src/test/resources/logback-test.xml | 2 +-
7 files changed, 13 insertions(+), 138 deletions(-)
diff --git a/src/test/java/org/example/Account.java b/src/test/java/org/example/Account.java
index 944602524..6caf527e3 100644
--- a/src/test/java/org/example/Account.java
+++ b/src/test/java/org/example/Account.java
@@ -1,41 +1,15 @@
-/**
- * Copyright (C) 2009 the original author or authors
- *
- * This file is part of Ebean.
- *
- * Ebean is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * Ebean is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Ebean; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
package org.example;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToOne;
-/**
- * The Class Account.
- * @since 18.05.2009
- * @author E Mc Greal
- */
@Entity
public class Account {
- /** The id. */
@Id
private Long id;
- /** The user. */
@OneToOne
private User user;
diff --git a/src/test/java/org/example/EbeanServerFactoryBean.java b/src/test/java/org/example/EbeanServerFactoryBean.java
index 295e5e90b..b5dc172ea 100644
--- a/src/test/java/org/example/EbeanServerFactoryBean.java
+++ b/src/test/java/org/example/EbeanServerFactoryBean.java
@@ -1,22 +1,3 @@
-/**
- * Copyright (C) 2009 the original author or authors
- *
- * This file is part of Ebean.
- *
- * Ebean is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * Ebean is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Ebean; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
package org.example;
import org.springframework.beans.factory.FactoryBean;
diff --git a/src/test/java/org/example/EbeanSpringModuleTest.java b/src/test/java/org/example/EbeanSpringModuleTest.java
index 54b1485af..58dcfd96d 100644
--- a/src/test/java/org/example/EbeanSpringModuleTest.java
+++ b/src/test/java/org/example/EbeanSpringModuleTest.java
@@ -1,30 +1,13 @@
-/**
- * Copyright (C) 2009 the original author or authors
- *
- * This file is part of Ebean.
- *
- * Ebean is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * Ebean is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Ebean; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
package org.example;
-import java.util.logging.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -38,7 +21,7 @@ import static org.junit.Assert.assertTrue;
public class EbeanSpringModuleTest {
/** The Constant logger. */
- private final static Logger logger = Logger.getLogger(EbeanSpringModuleTest.class.getName());
+ private final static Logger logger = LoggerFactory.getLogger(EbeanSpringModuleTest.class);
/** The user service. */
@Autowired
@@ -93,7 +76,8 @@ public class EbeanSpringModuleTest {
public void testFindNonTransactional() {
logger.info("Finding User with OID = 1 ...");
User user = userService.find(1);
- logger.info("nonTransactional find " + user);
+ User user2 = userService.findNoCurrentTransaction(2);
+ logger.info("nonTransactional find user1:{} user2:{}", user, user2);
}
/**
diff --git a/src/test/java/org/example/Role.java b/src/test/java/org/example/Role.java
index 41239de62..4f0a9434a 100644
--- a/src/test/java/org/example/Role.java
+++ b/src/test/java/org/example/Role.java
@@ -1,23 +1,3 @@
-/**
- * Copyright (C) 2009 the original author or authors
- *
- * This file is part of Ebean.
- *
- * Ebean is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * Ebean is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Ebean; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
package org.example;
import java.util.Set;
@@ -25,11 +5,6 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
-/**
- * The Class Role.
- * @since 18.05.2009
- * @author E Mc Greal
- */
@Entity
public class Role {
diff --git a/src/test/java/org/example/User.java b/src/test/java/org/example/User.java
index ec7bc2a1b..4cc235a9c 100644
--- a/src/test/java/org/example/User.java
+++ b/src/test/java/org/example/User.java
@@ -1,22 +1,3 @@
-/**
- * Copyright (C) 2009 the original author or authors
- *
- * This file is part of Ebean.
- *
- * Ebean is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * Ebean is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Ebean; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
package org.example;
import javax.persistence.Entity;
@@ -25,13 +6,9 @@ import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import java.util.Set;
-/**
- * The Class User.
- * @since 18.05.2009
- * @author E Mc Greal
- */
@Entity
public class User {
+
@Id
long oid;
@@ -40,9 +17,13 @@ public class User {
@ManyToMany
private Set roles;
- @OneToOne(mappedBy="user")
+ @OneToOne(mappedBy = "user")
private Account account;
+ public String toString() {
+ return "{user:" + oid + " name:" + name + "}";
+ }
+
public long getOid() {
return oid;
}
diff --git a/src/test/java/org/example/UserServiceImpl.java b/src/test/java/org/example/UserServiceImpl.java
index ccd6764ea..3e3b42dab 100644
--- a/src/test/java/org/example/UserServiceImpl.java
+++ b/src/test/java/org/example/UserServiceImpl.java
@@ -1,23 +1,3 @@
-/**
- * Copyright (C) 2009 the original author or authors
- *
- * This file is part of Ebean.
- *
- * Ebean is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * Ebean is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Ebean; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
package org.example;
import io.ebean.Transaction;
diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml
index e096c77e4..9bc1e1fa3 100644
--- a/src/test/resources/logback-test.xml
+++ b/src/test/resources/logback-test.xml
@@ -8,7 +8,7 @@
-
+
From 19491d5ae6c5ba0cc15119421c3acdd66ea4db5e Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Mon, 12 Mar 2018 21:45:14 +1300
Subject: [PATCH 067/116] #19 - java.lang.IllegalStateException: Transaction is
Inactive ... when using Ebean transactions with Ebean's Spring transaction
manager
---
.../txn/SpringJdbcTransactionManager.java | 7 +++---
.../org/example/EbeanSpringModuleTest.java | 23 +++++++++++++++++++
2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
index 30dd6ae88..fcac89aa6 100644
--- a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
+++ b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
@@ -71,12 +71,11 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
if (holder == null || !holder.isSynchronizedWithTransaction()) {
// no current Spring transaction
SpiTransaction currentEbeanTransaction = transactionManager.getInScope();
- if (currentEbeanTransaction != null && currentEbeanTransaction.isActive()) { // this is unexpected
- log.warn("No current Spring transaction BUT using current Ebean one {}", currentEbeanTransaction.getId());
+ if (currentEbeanTransaction == null || !currentEbeanTransaction.isActive()) {
+ return null;
} else {
- log.trace("No current Spring transaction");
+ return currentEbeanTransaction;
}
- return currentEbeanTransaction;
}
SpringTxnListener springTxnLister = getSpringTxnListener();
diff --git a/src/test/java/org/example/EbeanSpringModuleTest.java b/src/test/java/org/example/EbeanSpringModuleTest.java
index 58dcfd96d..7d5c05592 100644
--- a/src/test/java/org/example/EbeanSpringModuleTest.java
+++ b/src/test/java/org/example/EbeanSpringModuleTest.java
@@ -1,5 +1,7 @@
package org.example;
+import io.ebean.Ebean;
+import io.ebean.Transaction;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
@@ -34,6 +36,27 @@ public class EbeanSpringModuleTest {
super();
}
+ /**
+ * Test app.
+ */
+ @Test
+ public void testInactiveTransaction() {
+
+ Transaction transaction = Ebean.beginTransaction();
+ long id;
+ try {
+ User user = new User();
+ user.setName("save with txn 1");
+ Ebean.save(user);
+ transaction.commit();
+ id = user.getOid();
+ } finally {
+ // don't end the transaction ...
+ //transaction.end();
+ }
+
+ Ebean.delete(User.class, id);
+ }
@Test
public void testBatchInsert() {
From 4ee024b1ce1b4d7afa146baa156afb6d434f32a2 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Mon, 12 Mar 2018 21:45:45 +1300
Subject: [PATCH 068/116] [maven-release-plugin] prepare release
ebean-spring-txn-11.10.4
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 6385b363c..e515cc94c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 11.10.4-SNAPSHOT
+ 11.10.4
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- HEAD
+ ebean-spring-txn-11.10.4
From d9126a936d510d9f2ebfaf1080cf570741555eec Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Mon, 12 Mar 2018 21:45:57 +1300
Subject: [PATCH 069/116] [maven-release-plugin] prepare for next development
iteration
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index e515cc94c..0686abeae 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 11.10.4
+ 11.10.5-SNAPSHOT
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- ebean-spring-txn-11.10.4
+ HEAD
From 6705e5a962dff4b414a3d36f2071c82ca3fd2f82 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Thu, 8 Aug 2019 22:14:44 +1200
Subject: [PATCH 070/116] Bump Ebean provided dependency to 11.42.1
---
pom.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index 0686abeae..9bd824d85 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,7 +39,7 @@
io.ebean
ebean
- 11.10.3
+ 11.42.1
provided
@@ -120,11 +120,11 @@
io.repaint.maven
tiles-maven-plugin
- 2.8
+ 2.15
true
- io.ebean.tile:enhancement:5.2
+ io.ebean.tile:enhancement:11.40.1
From 7e8f413578c5f4f5be9808863b75f4320877ce2b Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Mon, 14 Oct 2019 14:52:46 +1300
Subject: [PATCH 071/116] No effective change - sync to Ebean 12.1.1
---
pom.xml | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/pom.xml b/pom.xml
index 9bd824d85..2489fa2af 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,13 +4,13 @@
org.avaje
- java8-parent
- 1.3
+ java8-oss
+ 2.1
io.ebean
ebean-spring-txn
- 11.10.5-SNAPSHOT
+ 12.1.1-SNAPSHOT
ebean-spring-txn
jar
@@ -39,7 +39,7 @@
io.ebean
ebean
- 11.42.1
+ 12.1.1
provided
@@ -124,7 +124,7 @@
true
- io.ebean.tile:enhancement:11.40.1
+ io.ebean.tile:enhancement:12.1.1
From 6fdf681993c98a3233ce8ecdb06ac85b0cdc8016 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Mon, 14 Oct 2019 14:53:19 +1300
Subject: [PATCH 072/116] [maven-release-plugin] prepare release
ebean-spring-txn-12.1.1
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 2489fa2af..4b366e0ed 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 12.1.1-SNAPSHOT
+ 12.1.1
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- HEAD
+ ebean-spring-txn-12.1.1
From 8c9dccc6a3893d0193067f7920d3413d735bcbc4 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Mon, 14 Oct 2019 14:53:28 +1300
Subject: [PATCH 073/116] [maven-release-plugin] prepare for next development
iteration
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 4b366e0ed..deff1c501 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 12.1.1
+ 12.1.2-SNAPSHOT
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- ebean-spring-txn-12.1.1
+ HEAD
From 21d377546e2f9fdb97a1f7abd23f63e17ed16987 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Fri, 13 Mar 2020 17:10:21 +1300
Subject: [PATCH 074/116] Bump to 12.2.1
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index deff1c501..26a7c86bb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 12.1.2-SNAPSHOT
+ 12.2.1-SNAPSHOT
ebean-spring-txn
jar
@@ -39,7 +39,7 @@
io.ebean
ebean
- 12.1.1
+ 12.2.1
provided
@@ -120,11 +120,11 @@
io.repaint.maven
tiles-maven-plugin
- 2.15
+ 2.16
true
- io.ebean.tile:enhancement:12.1.1
+ io.ebean.tile:enhancement:12.2.1
From 3ee4034a76ac0699796acb0d7eadc170d1e5901c Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Fri, 13 Mar 2020 17:12:15 +1300
Subject: [PATCH 075/116] [maven-release-plugin] prepare release
ebean-spring-txn-12.2.1
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 26a7c86bb..7c6ab3bad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 12.2.1-SNAPSHOT
+ 12.2.1
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- HEAD
+ ebean-spring-txn-12.2.1
From 23649ed840b180e31b73211ce0d7cec489b2c7e0 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Fri, 13 Mar 2020 17:12:25 +1300
Subject: [PATCH 076/116] [maven-release-plugin] prepare for next development
iteration
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 7c6ab3bad..0fce9c318 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 12.2.1
+ 12.2.2-SNAPSHOT
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- ebean-spring-txn-12.2.1
+ HEAD
From 95bb2a5d562a7a62ac7e23a844c5aa9803817d15 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Fri, 18 Sep 2020 01:14:52 +1200
Subject: [PATCH 077/116] Bump to 12.4.1
---
pom.xml | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/pom.xml b/pom.xml
index 0fce9c318..e774314e3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,12 +5,12 @@
org.avaje
java8-oss
- 2.1
+ 2.2
io.ebean
ebean-spring-txn
- 12.2.2-SNAPSHOT
+ 12.4.1-SNAPSHOT
ebean-spring-txn
jar
@@ -39,7 +39,7 @@
io.ebean
ebean
- 12.2.1
+ 12.4.1
provided
@@ -120,11 +120,11 @@
io.repaint.maven
tiles-maven-plugin
- 2.16
+ 2.17
true
- io.ebean.tile:enhancement:12.2.1
+ io.ebean.tile:enhancement:12.4.1
From c6483535bd0b2a082d09bc9ad0140d02d951ab99 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Fri, 18 Sep 2020 01:15:24 +1200
Subject: [PATCH 078/116] [maven-release-plugin] prepare release
ebean-spring-txn-12.4.1
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index e774314e3..6b6f695e3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 12.4.1-SNAPSHOT
+ 12.4.1
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- HEAD
+ ebean-spring-txn-12.4.1
From d3e78ab54ea773295090342bd21c23a517f47864 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Fri, 18 Sep 2020 01:15:35 +1200
Subject: [PATCH 079/116] [maven-release-plugin] prepare for next development
iteration
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 6b6f695e3..9b521bf21 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 12.4.1
+ 12.4.2-SNAPSHOT
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- ebean-spring-txn-12.4.1
+ HEAD
From 239f3a0a5488efddbde9950e0e3609e7d46f3a1a Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 13 Oct 2020 07:51:29 +0000
Subject: [PATCH 080/116] Bump junit from 4.12 to 4.13.1
Bumps [junit](https://github.com/junit-team/junit4) from 4.12 to 4.13.1.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.12.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.12...r4.13.1)
Signed-off-by: dependabot[bot]
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 9b521bf21..efb5931e7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -81,7 +81,7 @@
junit
junit
- 4.12
+ 4.13.1
test
From 94f367af70b1b9ce6dd3b6d5474297299a083ae6 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Fri, 18 Dec 2020 09:58:16 +1300
Subject: [PATCH 081/116] #22 - Spring @Transactional with batch mode not
invoking ebean batch flush
---
.../spring/txn/SpringJdbcTransactionManager.java | 12 +++---------
.../java/org/example/EbeanServerFactoryBean.java | 2 ++
src/test/java/org/example/EbeanSpringModuleTest.java | 6 ++++++
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
index fcac89aa6..ead75c2f4 100644
--- a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
+++ b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
@@ -49,7 +49,6 @@ public class SpringJdbcTransactionManager 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;
@@ -64,10 +63,8 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
*/
@Override
public Object getCurrentTransaction() {
-
// Get the current Spring ConnectionHolder associated to the current spring managed transaction
ConnectionHolder holder = (ConnectionHolder) TransactionSynchronizationManager.getResource(dataSource);
-
if (holder == null || !holder.isSynchronizedWithTransaction()) {
// no current Spring transaction
SpiTransaction currentEbeanTransaction = transactionManager.getInScope();
@@ -90,7 +87,6 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
// Create and register a Spring TransactionSynchronization for this transaction
springTxnLister = createSpringTxnListener(newTrans);
TransactionSynchronizationManager.registerSynchronization(springTxnLister);
-
return transactionManager.externalBeginTransaction(newTrans, TxScope.required());
}
}
@@ -102,7 +98,6 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
*
*/
private SpringTxnListener getSpringTxnListener() {
-
if (TransactionSynchronizationManager.isSynchronizationActive()) {
List synchronizations = TransactionSynchronizationManager.getSynchronizations();
if (synchronizations != null) {
@@ -114,7 +109,6 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
}
}
}
-
return null;
}
@@ -164,13 +158,13 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
@Override
public void beforeCommit(boolean readOnly) {
- // Future note: for JPA2 locking we will
- // have beforeCommit events to fire
+ if (!readOnly) {
+ transaction.flushBatch();
+ }
}
@Override
public void afterCompletion(int status) {
-
switch (status) {
case STATUS_COMMITTED:
log.debug("Spring Txn [{}] committed", transaction.getId());
diff --git a/src/test/java/org/example/EbeanServerFactoryBean.java b/src/test/java/org/example/EbeanServerFactoryBean.java
index b5dc172ea..41a128a8f 100644
--- a/src/test/java/org/example/EbeanServerFactoryBean.java
+++ b/src/test/java/org/example/EbeanServerFactoryBean.java
@@ -1,5 +1,6 @@
package org.example;
+import io.ebean.annotation.PersistBatch;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
@@ -31,6 +32,7 @@ public class EbeanServerFactoryBean implements InitializingBean, FactoryBean
Date: Fri, 18 Dec 2020 10:00:52 +1300
Subject: [PATCH 082/116] [maven-release-plugin] prepare release
ebean-spring-txn-12.4.2
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index efb5931e7..1285142ac 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 12.4.2-SNAPSHOT
+ 12.4.2
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- HEAD
+ ebean-spring-txn-12.4.2
From d1a4c73cd63ded9319116cca85311a7d15ca646d Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Fri, 18 Dec 2020 10:01:04 +1300
Subject: [PATCH 083/116] [maven-release-plugin] prepare for next development
iteration
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 1285142ac..f0202f23e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 12.4.2
+ 12.4.3-SNAPSHOT
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- ebean-spring-txn-12.4.2
+ HEAD
From bdfd38068775a50acac0b8660aa7f2e26565d912 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Fri, 18 Dec 2020 14:55:57 +1300
Subject: [PATCH 084/116] #23 - Use updated PostCommit to send ChangeLog
changes. Use PreCommit to flush last ChangeLog changes at PreCommit
---
pom.xml | 17 ++++++++++++-----
.../txn/SpringJdbcTransactionManager.java | 6 +++---
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/pom.xml b/pom.xml
index f0202f23e..9b7e70a7c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.avaje
java8-oss
- 2.2
+ 2.3
io.ebean
@@ -32,17 +32,24 @@
org.slf4j
slf4j-api
- 1.7.25
+ 1.7.30
provided
io.ebean
ebean
- 12.4.1
+ 12.6.3-SNAPSHOT
provided
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.12.0
+ test
+
+
org.springframework
@@ -120,11 +127,11 @@
io.repaint.maven
tiles-maven-plugin
- 2.17
+ 2.18
true
- io.ebean.tile:enhancement:12.4.1
+ io.ebean.tile:enhancement:12.6.1
diff --git a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
index ead75c2f4..1d9bc9030 100644
--- a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
+++ b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
@@ -159,7 +159,7 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
@Override
public void beforeCommit(boolean readOnly) {
if (!readOnly) {
- transaction.flushBatch();
+ transaction.preCommit();
}
}
@@ -168,12 +168,12 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
switch (status) {
case STATUS_COMMITTED:
log.debug("Spring Txn [{}] committed", transaction.getId());
- transactionManager.notifyOfCommit(transaction);
+ transaction.postCommit();
break;
case STATUS_ROLLED_BACK:
log.debug("Spring Txn [{}] rollback", transaction.getId());
- transactionManager.notifyOfRollback(transaction, null);
+ transaction.postRollback(null);
break;
default:
From 0be0fd1e05771e484a539508e8fc3ab65aeedd91 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Fri, 18 Dec 2020 15:28:31 +1300
Subject: [PATCH 085/116] Bump to 12.6.3-SNAPSHOT
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 9b7e70a7c..35797b4ae 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 12.4.3-SNAPSHOT
+ 12.6.3-SNAPSHOT
ebean-spring-txn
jar
@@ -39,7 +39,7 @@
io.ebean
ebean
- 12.6.3-SNAPSHOT
+ 12.6.3
provided
From 035c5570c3e3063ff1c9e485065fc290aa23db0b Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Fri, 18 Dec 2020 15:29:25 +1300
Subject: [PATCH 086/116] [maven-release-plugin] prepare release
ebean-spring-txn-12.6.3
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 35797b4ae..ec699d6d6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 12.6.3-SNAPSHOT
+ 12.6.3
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- HEAD
+ ebean-spring-txn-12.6.3
From 7077e92cb0d8b6b9ab6083e505d4d06d7e7296d8 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Fri, 18 Dec 2020 15:29:36 +1300
Subject: [PATCH 087/116] [maven-release-plugin] prepare for next development
iteration
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index ec699d6d6..db2758869 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 12.6.3
+ 12.6.4-SNAPSHOT
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- ebean-spring-txn-12.6.3
+ HEAD
From bf0c8d8dab58ce98f4f40d537d138b088b73f8d8 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Mon, 21 Dec 2020 14:45:13 +1300
Subject: [PATCH 088/116] Add test for transaction Propagation.REQUIRES_NEW
---
src/test/java/org/example/EbeanSpringModuleTest.java | 6 +++++-
src/test/java/org/example/UserService.java | 2 ++
src/test/java/org/example/UserServiceImpl.java | 7 +++++++
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/test/java/org/example/EbeanSpringModuleTest.java b/src/test/java/org/example/EbeanSpringModuleTest.java
index 1aa915e65..6fa5cf7c8 100644
--- a/src/test/java/org/example/EbeanSpringModuleTest.java
+++ b/src/test/java/org/example/EbeanSpringModuleTest.java
@@ -62,10 +62,14 @@ public class EbeanSpringModuleTest {
@Test
public void testBatchInsert() {
-
userService.batchInsert();
}
+ @Test
+ public void testRequiresNew() {
+ userService.requiresNew();
+ }
+
/**
* Test app.
*/
diff --git a/src/test/java/org/example/UserService.java b/src/test/java/org/example/UserService.java
index 33c037a54..6370601ba 100644
--- a/src/test/java/org/example/UserService.java
+++ b/src/test/java/org/example/UserService.java
@@ -14,4 +14,6 @@ public interface UserService {
void nonTransactional();
void batchInsert();
+
+ void requiresNew();
}
diff --git a/src/test/java/org/example/UserServiceImpl.java b/src/test/java/org/example/UserServiceImpl.java
index 3e3b42dab..599efb178 100644
--- a/src/test/java/org/example/UserServiceImpl.java
+++ b/src/test/java/org/example/UserServiceImpl.java
@@ -59,6 +59,13 @@ public class UserServiceImpl implements UserService {
System.out.println("---------after batch-------");
}
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
+ public void requiresNew() {
+ User user = new User();
+ user.setName("user_x0");
+ ebeanServer.save(user);
+ }
+
/**
* Return the ebean server.
From 559867294ff2ce65520441ba836aef5b37d75c39 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Mon, 21 Dec 2020 14:47:23 +1300
Subject: [PATCH 089/116] Add test for transaction Propagation.REQUIRES_NEW
---
src/test/java/org/example/User.java | 4 +++-
src/test/java/org/example/UserServiceImpl.java | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/test/java/org/example/User.java b/src/test/java/org/example/User.java
index 4cc235a9c..604caacf9 100644
--- a/src/test/java/org/example/User.java
+++ b/src/test/java/org/example/User.java
@@ -1,5 +1,7 @@
package org.example;
+import io.ebean.Model;
+
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
@@ -7,7 +9,7 @@ import javax.persistence.OneToOne;
import java.util.Set;
@Entity
-public class User {
+public class User extends Model {
@Id
long oid;
diff --git a/src/test/java/org/example/UserServiceImpl.java b/src/test/java/org/example/UserServiceImpl.java
index 599efb178..e935af82d 100644
--- a/src/test/java/org/example/UserServiceImpl.java
+++ b/src/test/java/org/example/UserServiceImpl.java
@@ -63,7 +63,8 @@ public class UserServiceImpl implements UserService {
public void requiresNew() {
User user = new User();
user.setName("user_x0");
- ebeanServer.save(user);
+ user.insert();
+ //ebeanServer.save(user);
}
From ddf9f5c50864c31df87488157072b871caa2680e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E6=B8=85=E6=B3=A2?=
Date: Mon, 21 Dec 2020 11:23:00 +0800
Subject: [PATCH 090/116] add fail situation for transaction
Propagation.REQUIRES_NEW
---
src/test/java/org/example/UserServiceImpl.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/test/java/org/example/UserServiceImpl.java b/src/test/java/org/example/UserServiceImpl.java
index e935af82d..3d77b3ce0 100644
--- a/src/test/java/org/example/UserServiceImpl.java
+++ b/src/test/java/org/example/UserServiceImpl.java
@@ -1,7 +1,10 @@
package org.example;
import io.ebean.Transaction;
+import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@@ -16,7 +19,9 @@ import java.util.List;
* @since 18.05.2009
* @author E Mc Greal
*/
-public class UserServiceImpl implements UserService {
+public class UserServiceImpl implements UserService, ApplicationContextAware {
+
+ private ApplicationContext applicationContext;
/** The ebean server. */
@Autowired
@@ -57,6 +62,8 @@ public class UserServiceImpl implements UserService {
ebeanServer.saveAll(users);
System.out.println("---------after batch-------");
+
+ applicationContext.getBean(UserService.class).requiresNew();
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
@@ -83,4 +90,8 @@ public class UserServiceImpl implements UserService {
}
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ this.applicationContext = applicationContext;
+ }
}
From 0e46558cae6b92918eb9a598dbabe694729e190e Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Wed, 23 Dec 2020 20:45:33 +1300
Subject: [PATCH 091/116] Bump ebean to 12.6.4 for #22
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index db2758869..2fe9bab85 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,7 +39,7 @@
io.ebean
ebean
- 12.6.3
+ 12.6.4
provided
From 9713b607b5593dcb31c06ba1816ff62d275c4d60 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Wed, 23 Dec 2020 20:46:10 +1300
Subject: [PATCH 092/116] [maven-release-plugin] prepare release
ebean-spring-txn-12.6.4
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 2fe9bab85..c2199e95b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 12.6.4-SNAPSHOT
+ 12.6.4
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- HEAD
+ ebean-spring-txn-12.6.4
From 5caae29df956ab9e213cd5c699b1e9fc20422280 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Wed, 23 Dec 2020 20:46:33 +1300
Subject: [PATCH 093/116] [maven-release-plugin] prepare for next development
iteration
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index c2199e95b..0ac04b399 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 12.6.4
+ 12.6.5-SNAPSHOT
ebean-spring-txn
jar
@@ -25,7 +25,7 @@
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
- ebean-spring-txn-12.6.4
+ HEAD
From bd1dd43cbf1d6c7906be570a768841a87b0c7660 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Mon, 16 Aug 2021 19:43:28 +1200
Subject: [PATCH 094/116] Bump to 12.11.0
---
pom.xml | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 0ac04b399..eeaf02027 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,12 +5,12 @@
org.avaje
java8-oss
- 2.3
+ 3.2
io.ebean
ebean-spring-txn
- 12.6.5-SNAPSHOT
+ 12.11.0
ebean-spring-txn
jar
@@ -39,10 +39,17 @@
io.ebean
ebean
- 12.6.4
+ 12.11.0
provided
+
+ io.ebean
+ ebean-ddl-generator
+ 12.11.0
+ test
+
+
com.fasterxml.jackson.core
jackson-databind
@@ -131,7 +138,7 @@
true
- io.ebean.tile:enhancement:12.6.1
+ io.ebean.tile:enhancement:12.11.0
From 56cb2c69aa128530986861b76fe5740a597889dc Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Mon, 16 Aug 2021 19:49:02 +1200
Subject: [PATCH 095/116] Bump to 12.11.1
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index eeaf02027..5c8ff9732 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,14 +39,14 @@
io.ebean
ebean
- 12.11.0
+ 12.11.1
provided
io.ebean
ebean-ddl-generator
- 12.11.0
+ 12.11.1
test
@@ -134,11 +134,11 @@
io.repaint.maven
tiles-maven-plugin
- 2.18
+ 2.20
true
- io.ebean.tile:enhancement:12.11.0
+ io.ebean.tile:enhancement:12.11.1
From 30f3d542b33582e64169f82c4ebe865b3dbac7e8 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Thu, 9 Sep 2021 13:10:13 +1200
Subject: [PATCH 096/116] Bump to 12.11.4
---
pom.xml | 4 ++--
.../io/ebean/spring/txn/SpringJdbcTransactionManager.java | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 5c8ff9732..1dae4782e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,14 +39,14 @@
io.ebean
ebean
- 12.11.1
+ 12.11.4-SNAPSHOT
provided
io.ebean
ebean-ddl-generator
- 12.11.1
+ 12.11.4A
test
diff --git a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
index 1d9bc9030..38a88a707 100644
--- a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
+++ b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
@@ -52,7 +52,7 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
// RB: At this stage not exposing TransactionManager to
// the public API and hence the Object type and casting here
this.transactionManager = (TransactionManager) txnMgr;
- this.dataSource = transactionManager.getDataSource();
+ this.dataSource = transactionManager.dataSource();
}
/**
@@ -67,7 +67,7 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
ConnectionHolder holder = (ConnectionHolder) TransactionSynchronizationManager.getResource(dataSource);
if (holder == null || !holder.isSynchronizedWithTransaction()) {
// no current Spring transaction
- SpiTransaction currentEbeanTransaction = transactionManager.getInScope();
+ SpiTransaction currentEbeanTransaction = transactionManager.inScope();
if (currentEbeanTransaction == null || !currentEbeanTransaction.isActive()) {
return null;
} else {
From a2c82263ee45ac566c65ebfd91159394c066698a Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Fri, 24 Sep 2021 11:29:50 +1200
Subject: [PATCH 097/116] Bump to 12.12.0
---
pom.xml | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/pom.xml b/pom.xml
index 1dae4782e..cc92f616e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 12.11.0
+ 12.12.0
ebean-spring-txn
jar
@@ -39,14 +39,14 @@
io.ebean
ebean
- 12.11.4-SNAPSHOT
+ 12.12.0
provided
io.ebean
ebean-ddl-generator
- 12.11.4A
+ 12.12.0
test
@@ -109,7 +109,7 @@
com.h2database
h2
- 1.4.196
+ 1.4.199
test
@@ -134,11 +134,11 @@
io.repaint.maven
tiles-maven-plugin
- 2.20
+ 2.24
true
- io.ebean.tile:enhancement:12.11.1
+ io.ebean.tile:enhancement:12.12.0
From 4084822d2ccaaa3afbc425dfe6e8c4f26d0d02ad Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Thu, 31 Mar 2022 14:38:41 +1300
Subject: [PATCH 098/116] Bump to 13.0.0 and Java 11
---
pom.xml | 17 +++++++++--------
src/main/java/module-info.java | 9 +++++++++
src/test/java/org/example/Account.java | 2 ++
src/test/java/org/example/Role.java | 2 ++
src/test/java/org/example/User.java | 6 ++----
5 files changed, 24 insertions(+), 12 deletions(-)
create mode 100644 src/main/java/module-info.java
diff --git a/pom.xml b/pom.xml
index cc92f616e..7448cb709 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,13 +4,13 @@
org.avaje
- java8-oss
- 3.2
+ java11-oss
+ 3.6
io.ebean
ebean-spring-txn
- 12.12.0
+ 13.0.0
ebean-spring-txn
jar
@@ -19,6 +19,7 @@
4.3.4.RELEASE
1.4.2.RELEASE
+ false
http://ebean-orm.github.io/
@@ -39,14 +40,14 @@
io.ebean
ebean
- 12.12.0
+ 13.0.0
provided
io.ebean
ebean-ddl-generator
- 12.12.0
+ 13.0.0
test
@@ -109,14 +110,14 @@
com.h2database
h2
- 1.4.199
+ 2.1.210
test
ch.qos.logback
logback-classic
- 1.2.3
+ 1.2.11
test
@@ -138,7 +139,7 @@
true
- io.ebean.tile:enhancement:12.12.0
+ io.ebean.tile:enhancement:13.0.0
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
new file mode 100644
index 000000000..52bb9ecf7
--- /dev/null
+++ b/src/main/java/module-info.java
@@ -0,0 +1,9 @@
+module io.ebean.spring.txn {
+
+ exports io.ebean.spring.txn;
+
+ requires io.ebean.api;
+ requires io.ebean.core;
+ requires spring.jdbc;
+ requires spring.tx;
+}
\ No newline at end of file
diff --git a/src/test/java/org/example/Account.java b/src/test/java/org/example/Account.java
index 6caf527e3..dea4c103d 100644
--- a/src/test/java/org/example/Account.java
+++ b/src/test/java/org/example/Account.java
@@ -3,7 +3,9 @@ package org.example;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToOne;
+import javax.persistence.Table;
+@Table(name="o_account")
@Entity
public class Account {
diff --git a/src/test/java/org/example/Role.java b/src/test/java/org/example/Role.java
index 4f0a9434a..6fcee501e 100644
--- a/src/test/java/org/example/Role.java
+++ b/src/test/java/org/example/Role.java
@@ -4,7 +4,9 @@ import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+@Table(name="o_role")
@Entity
public class Role {
diff --git a/src/test/java/org/example/User.java b/src/test/java/org/example/User.java
index 604caacf9..337796f06 100644
--- a/src/test/java/org/example/User.java
+++ b/src/test/java/org/example/User.java
@@ -2,12 +2,10 @@ package org.example;
import io.ebean.Model;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.ManyToMany;
-import javax.persistence.OneToOne;
+import javax.persistence.*;
import java.util.Set;
+@Table(name="o_user")
@Entity
public class User extends Model {
From 610afd371751b3e8feee9a941742160b5ba738c3 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Mon, 5 Sep 2022 19:33:40 +1200
Subject: [PATCH 099/116] Update tests
---
.../org/example/EbeanServerFactoryBean.java | 25 ++--
.../org/example/EbeanSpringModuleTest.java | 7 +-
.../java/org/example/UserServiceImpl.java | 127 +++++++++---------
src/test/resources/default-ebean-server.xml | 2 +-
4 files changed, 80 insertions(+), 81 deletions(-)
diff --git a/src/test/java/org/example/EbeanServerFactoryBean.java b/src/test/java/org/example/EbeanServerFactoryBean.java
index 41a128a8f..935a2d224 100644
--- a/src/test/java/org/example/EbeanServerFactoryBean.java
+++ b/src/test/java/org/example/EbeanServerFactoryBean.java
@@ -1,30 +1,29 @@
package org.example;
+import io.ebean.Database;
+import io.ebean.DatabaseFactory;
import io.ebean.annotation.PersistBatch;
+import io.ebean.config.DatabaseConfig;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
-import io.ebean.EbeanServer;
-import io.ebean.EbeanServerFactory;
-import io.ebean.config.ServerConfig;
-
/**
* A Spring FactoryBean for constructing EbeanServer instances.
*
* @since 18.05.2009
* @author E Mc Greal
*/
-public class EbeanServerFactoryBean implements InitializingBean, FactoryBean {
+public class EbeanServerFactoryBean implements InitializingBean, FactoryBean {
/**
* The Ebean server configuration.
*/
- private ServerConfig serverConfig;
+ private DatabaseConfig serverConfig;
/**
* The EbeanServer instance.
*/
- private EbeanServer ebeanServer;
+ private Database ebeanServer;
public void afterPropertiesSet() throws Exception {
@@ -34,15 +33,15 @@ public class EbeanServerFactoryBean implements InitializingBean, FactoryBean getObjectType() {
- return EbeanServer.class;
+ public Class extends Database> getObjectType() {
+ return Database.class;
}
/**
@@ -55,14 +54,14 @@ public class EbeanServerFactoryBean implements InitializingBean, FactoryBean users = new ArrayList<>();
- for(int i=0 ;i<25;i++){
- User user = new User();
- user.setName("user"+i);
- users.add(user);
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
+ public void save(User user) {
+ ebeanServer.save(user);
}
- System.out.println("---------before batch-------");
+ @Transactional(readOnly = true, propagation = Propagation.REQUIRED)
+ public User find(long id) {
+ return ebeanServer.find(User.class, id);
+ }
- Transaction tx = ebeanServer.currentTransaction();
- tx.setBatchSize(20);
- ebeanServer.saveAll(users);
+ public void nonTransactional() {
+ ebeanServer.currentTransaction();
+ }
- System.out.println("---------after batch-------");
+ public User findNoCurrentTransaction(long id) {
+ return ebeanServer.find(User.class, id);
+ }
- applicationContext.getBean(UserService.class).requiresNew();
- }
+ @Transactional(propagation = Propagation.REQUIRED)
+ public void batchInsert() {
- @Transactional(propagation = Propagation.REQUIRES_NEW)
- public void requiresNew() {
- User user = new User();
- user.setName("user_x0");
- user.insert();
- //ebeanServer.save(user);
- }
+ List users = new ArrayList<>();
+ for (int i = 0; i < 25; i++) {
+ User user = new User();
+ user.setName("user" + i);
+ users.add(user);
+ }
+
+ System.out.println("---------before batch-------");
+
+ Transaction tx = ebeanServer.currentTransaction();
+ tx.setBatchSize(20);
+ ebeanServer.saveAll(users);
+
+ System.out.println("---------after batch-------");
+
+ applicationContext.getBean(UserService.class).requiresNew();
+ }
+
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
+ public void requiresNew() {
+ User user = new User();
+ user.setName("user_x0");
+ user.insert();
+ //ebeanServer.save(user);
+ }
- /**
- * Return the ebean server.
- */
- public EbeanServer getEbeanServer() {
- return ebeanServer;
- }
+ /**
+ * Return the ebean server.
+ */
+ public Database getEbeanServer() {
+ return ebeanServer;
+ }
- /**
- * Sets the ebean server.
- */
- public void setEbeanServer(EbeanServer ebeanServer) {
- this.ebeanServer = ebeanServer;
- }
+ /**
+ * Sets the ebean server.
+ */
+ public void setEbeanServer(Database ebeanServer) {
+ this.ebeanServer = ebeanServer;
+ }
- @Override
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
- this.applicationContext = applicationContext;
- }
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ this.applicationContext = applicationContext;
+ }
}
diff --git a/src/test/resources/default-ebean-server.xml b/src/test/resources/default-ebean-server.xml
index 44da26196..87ebce8bd 100644
--- a/src/test/resources/default-ebean-server.xml
+++ b/src/test/resources/default-ebean-server.xml
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd">
-
+
From 3be3741db60574e59c7ab1f253bffdfb9fee9e02 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Mon, 5 Sep 2022 19:35:52 +1200
Subject: [PATCH 100/116] Change to use System.Logger + transaction.flush()
---
pom.xml | 18 +++++++++---------
.../txn/SpringJdbcTransactionManager.java | 13 +++++++------
2 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/pom.xml b/pom.xml
index 7448cb709..821468a4b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,28 +33,28 @@
org.slf4j
slf4j-api
- 1.7.30
+ 2.0.0
provided
io.ebean
ebean
- 13.0.0
+ 13.9.2
provided
io.ebean
ebean-ddl-generator
- 13.0.0
+ 13.9.2
test
com.fasterxml.jackson.core
jackson-databind
- 2.12.0
+ 2.13.3
test
@@ -96,21 +96,21 @@
junit
junit
- 4.13.1
+ 4.13.2
test
org.assertj
assertj-core
- 3.1.0
+ 3.23.1
test
com.h2database
h2
- 2.1.210
+ 2.1.214
test
@@ -124,7 +124,7 @@
org.slf4j
jcl-over-slf4j
- [1.7,)
+ 2.0.0
test
@@ -139,7 +139,7 @@
true
- io.ebean.tile:enhancement:13.0.0
+ io.ebean.tile:enhancement:13.9.1
diff --git a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
index 38a88a707..cb478ce16 100644
--- a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
+++ b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
@@ -1,11 +1,10 @@
package io.ebean.spring.txn;
+import io.avaje.applog.AppLog;
import io.ebean.TxScope;
import io.ebean.config.ExternalTransactionManager;
import io.ebeaninternal.api.SpiTransaction;
import io.ebeaninternal.server.transaction.TransactionManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.jdbc.datasource.ConnectionHolder;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationAdapter;
@@ -15,6 +14,8 @@ import javax.persistence.PersistenceException;
import javax.sql.DataSource;
import java.util.List;
+import static java.lang.System.Logger.Level.DEBUG;
+
/**
* A Spring-aware {@link ExternalTransactionManager}.
*
@@ -26,7 +27,7 @@ import java.util.List;
*/
public class SpringJdbcTransactionManager implements ExternalTransactionManager {
- private static final Logger log = LoggerFactory.getLogger(SpringJdbcTransactionManager.class);
+ private static final System.Logger log = AppLog.getLogger(SpringJdbcTransactionManager.class);
/**
* The data source.
@@ -153,7 +154,7 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
@Override
public void flush() {
- transaction.flushBatch();
+ transaction.flush();
}
@Override
@@ -167,12 +168,12 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
public void afterCompletion(int status) {
switch (status) {
case STATUS_COMMITTED:
- log.debug("Spring Txn [{}] committed", transaction.getId());
+ log.log(DEBUG, "Spring Txn [{0}] committed", transaction.getId());
transaction.postCommit();
break;
case STATUS_ROLLED_BACK:
- log.debug("Spring Txn [{}] rollback", transaction.getId());
+ log.log(DEBUG, "Spring Txn [{0}] rollback", transaction.getId());
transaction.postRollback(null);
break;
From 6e340bd1490c3f42f5a2683dd53a26a46690c5b5 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Mon, 5 Sep 2022 19:40:21 +1200
Subject: [PATCH 101/116] Bump parent and version
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 821468a4b..e9b74e6c8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,12 +5,12 @@
org.avaje
java11-oss
- 3.6
+ 3.9
io.ebean
ebean-spring-txn
- 13.0.0
+ 13.9.0
ebean-spring-txn
jar
From 6b730729828593f5bc50fca443746d2a434a44b8 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Wed, 7 Sep 2022 12:48:45 +1200
Subject: [PATCH 102/116] Make SpringJdbcTransactionManager final,
SpringJdbcTransaction not public
---
.../spring/txn/SpringJdbcTransaction.java | 12 ++---
.../txn/SpringJdbcTransactionManager.java | 48 ++++++-------------
2 files changed, 17 insertions(+), 43 deletions(-)
diff --git a/src/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java b/src/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java
index f86433b53..7ef394b45 100644
--- a/src/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java
+++ b/src/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java
@@ -17,19 +17,17 @@
* along with Ebean; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
package io.ebean.spring.txn;
-import org.springframework.jdbc.datasource.ConnectionHolder;
-
import io.ebeaninternal.server.transaction.ExternalJdbcTransaction;
import io.ebeaninternal.server.transaction.TransactionManager;
+import org.springframework.jdbc.datasource.ConnectionHolder;
-public class SpringJdbcTransaction extends ExternalJdbcTransaction {
+final class SpringJdbcTransaction extends ExternalJdbcTransaction {
private final ConnectionHolder holder;
- public SpringJdbcTransaction(ConnectionHolder holder, TransactionManager manager) {
+ SpringJdbcTransaction(ConnectionHolder holder, TransactionManager manager) {
super("s" + holder.hashCode(), true, holder.getConnection(), manager);
this.holder = holder;
}
@@ -38,8 +36,4 @@ public class SpringJdbcTransaction extends ExternalJdbcTransaction {
public boolean isActive() {
return holder.isSynchronizedWithTransaction();
}
-
- public ConnectionHolder getConnectionHolder() {
- return holder;
- }
}
diff --git a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
index cb478ce16..3dc6f0377 100644
--- a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
+++ b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
@@ -20,23 +20,15 @@ import static java.lang.System.Logger.Level.DEBUG;
* A Spring-aware {@link ExternalTransactionManager}.
*
* Will look for Spring transactions and use them if they exist.
- *
*
* @since 18.05.2009
* @author E Mc Greal
*/
-public class SpringJdbcTransactionManager implements ExternalTransactionManager {
+public final class SpringJdbcTransactionManager implements ExternalTransactionManager {
private static final System.Logger log = AppLog.getLogger(SpringJdbcTransactionManager.class);
- /**
- * The data source.
- */
private DataSource dataSource;
-
- /**
- * The Ebean transaction manager.
- */
private TransactionManager transactionManager;
/**
@@ -59,8 +51,7 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
/**
* Looks for a current Spring managed transaction and wraps/returns that as a Ebean transaction.
*
- * Returns null if there is no current spring transaction (lazy loading outside a spring txn etc).
- *
+ * Returns null if there is no current spring transaction (lazy loading outside a spring txn).
*/
@Override
public Object getCurrentTransaction() {
@@ -76,17 +67,17 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
}
}
- SpringTxnListener springTxnLister = getSpringTxnListener();
+ SpringTxnListener springTxnLister = listener();
if (springTxnLister != null) {
// we have already seen this transaction
- return springTxnLister.getTransaction();
+ return springTxnLister.transaction();
} else {
// This is a new spring transaction that we have not seen before.
// "wrap" it in a SpringJdbcTransaction for use with Ebean
SpringJdbcTransaction newTrans = new SpringJdbcTransaction(holder, transactionManager);
// Create and register a Spring TransactionSynchronization for this transaction
- springTxnLister = createSpringTxnListener(newTrans);
+ springTxnLister = createListener(newTrans);
TransactionSynchronizationManager.registerSynchronization(springTxnLister);
return transactionManager.externalBeginTransaction(newTrans, TxScope.required());
}
@@ -96,9 +87,8 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
* Search for our specific transaction listener.
*
* If it exists then we have already seen and "wrapped" this transaction.
- *
*/
- private SpringTxnListener getSpringTxnListener() {
+ private SpringTxnListener listener() {
if (TransactionSynchronizationManager.isSynchronizationActive()) {
List synchronizations = TransactionSynchronizationManager.getSynchronizations();
if (synchronizations != null) {
@@ -114,25 +104,18 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
}
/**
- * Create a listener to register with Spring to enable Ebean to be
- * notified when transactions commit and rollback.
- *
- * This is used by Ebean to notify it's appropriate listeners and maintain it's server
- * cache etc.
- *
+ * Create a listener to enable Ebean to be notified when transactions commit and rollback.
*/
- private SpringTxnListener createSpringTxnListener(SpringJdbcTransaction t) {
- return new SpringTxnListener(transactionManager, t);
+ private SpringTxnListener createListener(SpringJdbcTransaction transaction) {
+ return new SpringTxnListener(transactionManager, transaction);
}
/**
- * A Spring TransactionSynchronization that we register with Spring to get
- * notified when a Spring managed transaction has been committed or rolled
- * back.
+ * A Spring TransactionSynchronization that we register with Spring to get notified when
+ * a Spring managed transaction has been committed or rolled back.
*
- * When Ebean is notified (of the commit/rollback) it can then manage its
- * cache, notify BeanPersistListeners etc.
- *
+ * When Ebean is notified (of the commit/rollback) it can then manage its cache, notify
+ * BeanPersistListeners etc.
*/
private static class SpringTxnListener extends TransactionSynchronizationAdapter {
@@ -145,10 +128,7 @@ public class SpringJdbcTransactionManager implements ExternalTransactionManager
this.transaction = t;
}
- /**
- * Return the associated Ebean wrapped transaction.
- */
- SpringJdbcTransaction getTransaction() {
+ private SpringJdbcTransaction transaction() {
return transaction;
}
From c3dc57f0fb8834c3124e9ea13fe05768d482bc49 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Wed, 7 Sep 2022 13:21:04 +1200
Subject: [PATCH 103/116] Bump the spring dependency versions used in testing
---
.editorconfig | 13 +++++++++++++
pom.xml | 7 +++----
2 files changed, 16 insertions(+), 4 deletions(-)
create mode 100644 .editorconfig
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..18b710430
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,13 @@
+# editorconfig.org
+
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_size = 2
+indent_style = space
+insert_final_newline = true
+trim_trailing_whitespace = true
+spaces_around_operators = true
+max_line_length = 130
diff --git a/pom.xml b/pom.xml
index e9b74e6c8..33a48d9f8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,13 +17,12 @@
Ebean support for Spring transactions
- 4.3.4.RELEASE
- 1.4.2.RELEASE
+ 5.3.22
+ 2.7.3
false
- http://ebean-orm.github.io/
-
+ https://ebean.io/
scm:git:git@github.com:ebean-orm/ebean-spring-txn.git
HEAD
From 4619c56b09e34d995448780b0fe1b7fbb58ce0b0 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Wed, 7 Sep 2022 13:34:23 +1200
Subject: [PATCH 104/116] #31 - Explicitly add Apache 2 License text (it got
missed when ebean changed from LGPL to Apache2)
---
LICENSE | 201 ++++++++++++++++++
.../spring/txn/SpringJdbcTransaction.java | 19 --
.../txn/SpringJdbcTransactionManager.java | 2 +-
3 files changed, 202 insertions(+), 20 deletions(-)
create mode 100644 LICENSE
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 000000000..1ab0a32fa
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2012 Authors
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/src/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java b/src/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java
index 7ef394b45..424f1a239 100644
--- a/src/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java
+++ b/src/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java
@@ -1,22 +1,3 @@
-/**
- * Copyright (C) 2009 the original author or authors
- *
- * This file is part of Ebean.
- *
- * Ebean is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * Ebean is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Ebean; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
package io.ebean.spring.txn;
import io.ebeaninternal.server.transaction.ExternalJdbcTransaction;
diff --git a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
index 3dc6f0377..409d751b5 100644
--- a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
+++ b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
@@ -21,8 +21,8 @@ import static java.lang.System.Logger.Level.DEBUG;
*
* Will look for Spring transactions and use them if they exist.
*
- * @since 18.05.2009
* @author E Mc Greal
+ * @since 18.05.2009
*/
public final class SpringJdbcTransactionManager implements ExternalTransactionManager {
From 03bd31677a58acbc9c0cc6df8a5f0af412bb31d9 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Wed, 7 Sep 2022 13:35:26 +1200
Subject: [PATCH 105/116] Bump to 13.9.1
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 33a48d9f8..4715f2d84 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 13.9.0
+ 13.9.1
ebean-spring-txn
jar
From dd95081e631b6f9d13cfd734506a029ced9890ee Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Wed, 7 Sep 2022 14:03:37 +1200
Subject: [PATCH 106/116] Update use example in README
---
README.md | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 617ad1433..6e66440ff 100644
--- a/README.md
+++ b/README.md
@@ -9,21 +9,34 @@ to integrate with Springs JDBC Transaction manager.
## To use
```java
-ServerConfig serverConfig = new ServerConfig();
+DatabaseConfig config = new DatabaseConfig();
// set SpringJdbcTransactionManager ... as the external transaction manager
-serverConfig.setExternalTransactionManager(new SpringJdbcTransactionManager());
+config.setExternalTransactionManager(new SpringJdbcTransactionManager());
...
-EbeanServer server = EbeanServerFactory.create(serverConfig);
+Database database = DatabaseFactory.create(config);
```
## Notes
You can use Ebean in Spring/Spring Boot *without* this and that case Ebean
-manages the Transactions itself. With Ebean managing the transactions there
+manages the Transactions itself. With Ebean managing the transactions there
are some benefits with more control over JDBC batch, getGeneratedKeys
and a simpler abstraction (as Spring transactions is designed to manage
multiple resources such as JDBC Transactions and JPA EntityManager and Ebean
-only needs to manage JDBC Transactions).
\ No newline at end of file
+only needs to manage JDBC Transactions).
+
+
+## Java modules
+
+The module name is `io.ebean.spring.txn`
+
+```java
+module foo {
+
+ requires io.ebean.spring.txn;
+ ...
+}
+```
From e00e490e7306b3a125346e7ef0f02ebbdc5c3f28 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Wed, 7 Sep 2022 14:09:49 +1200
Subject: [PATCH 107/116] Update use example in README
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 6e66440ff..ce1398656 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,7 @@ only needs to manage JDBC Transactions).
## Java modules
-The module name is `io.ebean.spring.txn`
+Add `requires io.ebean.spring.txn` to module-info.
```java
module foo {
From 4e3cd83e363027ab594cefff7a8493d1658a75ee Mon Sep 17 00:00:00 2001
From: rob
Date: Tue, 14 Feb 2023 22:29:02 +1300
Subject: [PATCH 108/116] #33 - Update internals from using deprecated
TransactionSynchronizationAdapter to TransactionSynchronization
---
pom.xml | 2 +-
.../spring/txn/SpringJdbcTransactionManager.java | 13 +++++--------
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/pom.xml b/pom.xml
index 4715f2d84..3fd94712e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,7 +17,7 @@
Ebean support for Spring transactions
- 5.3.22
+ 5.3.18
2.7.3
false
diff --git a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
index 409d751b5..8375acf7c 100644
--- a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
+++ b/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
@@ -7,7 +7,6 @@ import io.ebeaninternal.api.SpiTransaction;
import io.ebeaninternal.server.transaction.TransactionManager;
import org.springframework.jdbc.datasource.ConnectionHolder;
import org.springframework.transaction.support.TransactionSynchronization;
-import org.springframework.transaction.support.TransactionSynchronizationAdapter;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import javax.persistence.PersistenceException;
@@ -91,12 +90,10 @@ public final class SpringJdbcTransactionManager implements ExternalTransactionMa
private SpringTxnListener listener() {
if (TransactionSynchronizationManager.isSynchronizationActive()) {
List synchronizations = TransactionSynchronizationManager.getSynchronizations();
- if (synchronizations != null) {
- // search for our specific listener
- for (TransactionSynchronization synchronization : synchronizations) {
- if (synchronization instanceof SpringTxnListener) {
- return (SpringTxnListener) synchronization;
- }
+ // search for our specific listener
+ for (TransactionSynchronization synchronization : synchronizations) {
+ if (synchronization instanceof SpringTxnListener) {
+ return (SpringTxnListener) synchronization;
}
}
}
@@ -117,7 +114,7 @@ public final class SpringJdbcTransactionManager implements ExternalTransactionMa
* When Ebean is notified (of the commit/rollback) it can then manage its cache, notify
* BeanPersistListeners etc.
*/
- private static class SpringTxnListener extends TransactionSynchronizationAdapter {
+ private static class SpringTxnListener implements TransactionSynchronization {
private final TransactionManager transactionManager;
From 658b5b7e069e1e7e89494c912bfccfacb4e17680 Mon Sep 17 00:00:00 2001
From: rob
Date: Tue, 14 Feb 2023 22:29:45 +1300
Subject: [PATCH 109/116] Bump version to 13.10.0
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 3fd94712e..21e6d9c45 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 13.9.1
+ 13.10.0
ebean-spring-txn
jar
From 2aa92d63fd6bb80870a391e3c0f63836dd6ea814 Mon Sep 17 00:00:00 2001
From: rob
Date: Tue, 14 Feb 2023 22:32:04 +1300
Subject: [PATCH 110/116] Bump test dependency Jackson
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 21e6d9c45..37b5adafc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -53,7 +53,7 @@
com.fasterxml.jackson.core
jackson-databind
- 2.13.3
+ 2.14.1
test
From 5b4ff2627c4caef510faaf01c37d025925d0aa7b Mon Sep 17 00:00:00 2001
From: rob
Date: Tue, 14 Feb 2023 22:36:27 +1300
Subject: [PATCH 111/116] Bump provided spring dependency to latest in 5.3 to
avoid security pings on the older dependency
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 37b5adafc..d26e0d7c3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,7 +17,7 @@
Ebean support for Spring transactions
- 5.3.18
+ 5.3.25
2.7.3
false
From 82fd6dc65fe67cf748123a7304aae4809cd60b32 Mon Sep 17 00:00:00 2001
From: rob
Date: Tue, 14 Feb 2023 23:24:09 +1300
Subject: [PATCH 112/116] Add badges to README
---
README.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/README.md b/README.md
index ce1398656..a49f215e2 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,6 @@
+[](https://maven-badges.herokuapp.com/maven-central/io.ebean/ebean-spring-txn)
+[](https://github.com/ebean-orm/ebean-spring-txn/blob/master/LICENSE)
+
ebean-spring-txn
=====================
From a9575048b4429a0bd8f759ed436ce39f2a9e97e5 Mon Sep 17 00:00:00 2001
From: rob
Date: Fri, 17 Feb 2023 21:02:46 +1300
Subject: [PATCH 113/116] Change to support Ebean 13.13.0
FYI: Also put the provided slf4j-api back to 1.7.x to see the logs when running tests
---
pom.xml | 8 ++++----
.../java/io/ebean/spring/txn/SpringJdbcTransaction.java | 2 +-
src/test/resources/logback-test.xml | 5 +----
3 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/pom.xml b/pom.xml
index d26e0d7c3..5c9380faf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 13.10.0
+ 13.13.0
ebean-spring-txn
jar
@@ -32,21 +32,21 @@
org.slf4j
slf4j-api
- 2.0.0
+ 1.7.32
provided
io.ebean
ebean
- 13.9.2
+ 13.13.0
provided
io.ebean
ebean-ddl-generator
- 13.9.2
+ 13.13.0
test
diff --git a/src/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java b/src/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java
index 424f1a239..d8208d900 100644
--- a/src/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java
+++ b/src/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java
@@ -9,7 +9,7 @@ final class SpringJdbcTransaction extends ExternalJdbcTransaction {
private final ConnectionHolder holder;
SpringJdbcTransaction(ConnectionHolder holder, TransactionManager manager) {
- super("s" + holder.hashCode(), true, holder.getConnection(), manager);
+ super(true, holder.getConnection(), manager);
this.holder = holder;
}
diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml
index 9bc1e1fa3..6512a5202 100644
--- a/src/test/resources/logback-test.xml
+++ b/src/test/resources/logback-test.xml
@@ -1,8 +1,5 @@
-
- TRACE
-
%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
@@ -29,4 +26,4 @@
-
\ No newline at end of file
+
From 1c8a416de0054abe7eaa3a4805f9f1eaf4d3805f Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Tue, 7 Mar 2023 00:21:19 +1300
Subject: [PATCH 114/116] Use ebean-core as provided dependency
- ebean-core as provided dependency
- ebean-h2 as test dependency
---
pom.xml | 9 ++++++++-
src/main/java/module-info.java | 2 +-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 5c9380faf..37446b906 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,11 +38,18 @@
io.ebean
- ebean
+ ebean-core
13.13.0
provided
+
+ io.ebean
+ ebean-h2
+ 13.13.0
+ test
+
+
io.ebean
ebean-ddl-generator
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
index 52bb9ecf7..13c688f67 100644
--- a/src/main/java/module-info.java
+++ b/src/main/java/module-info.java
@@ -6,4 +6,4 @@ module io.ebean.spring.txn {
requires io.ebean.core;
requires spring.jdbc;
requires spring.tx;
-}
\ No newline at end of file
+}
From 801cb6fa7340b11a02b99da9f1ade600c5824277 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Tue, 7 Mar 2023 00:36:46 +1300
Subject: [PATCH 115/116] Bump to 13.14.0
---
pom.xml | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/pom.xml b/pom.xml
index 37446b906..8761d3224 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
io.ebean
ebean-spring-txn
- 13.13.0
+ 13.14.0
ebean-spring-txn
jar
@@ -39,21 +39,21 @@
io.ebean
ebean-core
- 13.13.0
+ 13.14.0
provided
io.ebean
ebean-h2
- 13.13.0
+ 13.14.0
test
io.ebean
ebean-ddl-generator
- 13.13.0
+ 13.14.0
test
@@ -145,7 +145,7 @@
true
- io.ebean.tile:enhancement:13.9.1
+ io.ebean.tile:enhancement:13.14.0
From 9a02618b67dadce31dcd7fc4f5e9e63771536137 Mon Sep 17 00:00:00 2001
From: Rob Bygrave
Date: Tue, 7 Mar 2023 00:56:28 +1300
Subject: [PATCH 116/116] Move into ebean-spring-txn subdirectory
---
.editorconfig => ebean-spring-txn/.editorconfig | 0
.gitignore => ebean-spring-txn/.gitignore | 0
LICENSE => ebean-spring-txn/LICENSE | 0
README.md => ebean-spring-txn/README.md | 0
pom.xml => ebean-spring-txn/pom.xml | 0
.../src}/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java | 0
.../java/io/ebean/spring/txn/SpringJdbcTransactionManager.java | 0
{src => ebean-spring-txn/src}/main/java/module-info.java | 0
{src => ebean-spring-txn/src}/test/java/org/example/Account.java | 0
.../src}/test/java/org/example/EbeanServerFactoryBean.java | 0
.../src}/test/java/org/example/EbeanSpringModuleTest.java | 0
{src => ebean-spring-txn/src}/test/java/org/example/Role.java | 0
{src => ebean-spring-txn/src}/test/java/org/example/User.java | 0
.../src}/test/java/org/example/UserService.java | 0
.../src}/test/java/org/example/UserServiceImpl.java | 0
.../src}/test/resources/default-ebean-server.xml | 0
{src => ebean-spring-txn/src}/test/resources/init-database.xml | 0
{src => ebean-spring-txn/src}/test/resources/logback-test.xml | 0
18 files changed, 0 insertions(+), 0 deletions(-)
rename .editorconfig => ebean-spring-txn/.editorconfig (100%)
rename .gitignore => ebean-spring-txn/.gitignore (100%)
rename LICENSE => ebean-spring-txn/LICENSE (100%)
rename README.md => ebean-spring-txn/README.md (100%)
rename pom.xml => ebean-spring-txn/pom.xml (100%)
rename {src => ebean-spring-txn/src}/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java (100%)
rename {src => ebean-spring-txn/src}/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java (100%)
rename {src => ebean-spring-txn/src}/main/java/module-info.java (100%)
rename {src => ebean-spring-txn/src}/test/java/org/example/Account.java (100%)
rename {src => ebean-spring-txn/src}/test/java/org/example/EbeanServerFactoryBean.java (100%)
rename {src => ebean-spring-txn/src}/test/java/org/example/EbeanSpringModuleTest.java (100%)
rename {src => ebean-spring-txn/src}/test/java/org/example/Role.java (100%)
rename {src => ebean-spring-txn/src}/test/java/org/example/User.java (100%)
rename {src => ebean-spring-txn/src}/test/java/org/example/UserService.java (100%)
rename {src => ebean-spring-txn/src}/test/java/org/example/UserServiceImpl.java (100%)
rename {src => ebean-spring-txn/src}/test/resources/default-ebean-server.xml (100%)
rename {src => ebean-spring-txn/src}/test/resources/init-database.xml (100%)
rename {src => ebean-spring-txn/src}/test/resources/logback-test.xml (100%)
diff --git a/.editorconfig b/ebean-spring-txn/.editorconfig
similarity index 100%
rename from .editorconfig
rename to ebean-spring-txn/.editorconfig
diff --git a/.gitignore b/ebean-spring-txn/.gitignore
similarity index 100%
rename from .gitignore
rename to ebean-spring-txn/.gitignore
diff --git a/LICENSE b/ebean-spring-txn/LICENSE
similarity index 100%
rename from LICENSE
rename to ebean-spring-txn/LICENSE
diff --git a/README.md b/ebean-spring-txn/README.md
similarity index 100%
rename from README.md
rename to ebean-spring-txn/README.md
diff --git a/pom.xml b/ebean-spring-txn/pom.xml
similarity index 100%
rename from pom.xml
rename to ebean-spring-txn/pom.xml
diff --git a/src/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java b/ebean-spring-txn/src/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java
similarity index 100%
rename from src/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java
rename to ebean-spring-txn/src/main/java/io/ebean/spring/txn/SpringJdbcTransaction.java
diff --git a/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java b/ebean-spring-txn/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
similarity index 100%
rename from src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
rename to ebean-spring-txn/src/main/java/io/ebean/spring/txn/SpringJdbcTransactionManager.java
diff --git a/src/main/java/module-info.java b/ebean-spring-txn/src/main/java/module-info.java
similarity index 100%
rename from src/main/java/module-info.java
rename to ebean-spring-txn/src/main/java/module-info.java
diff --git a/src/test/java/org/example/Account.java b/ebean-spring-txn/src/test/java/org/example/Account.java
similarity index 100%
rename from src/test/java/org/example/Account.java
rename to ebean-spring-txn/src/test/java/org/example/Account.java
diff --git a/src/test/java/org/example/EbeanServerFactoryBean.java b/ebean-spring-txn/src/test/java/org/example/EbeanServerFactoryBean.java
similarity index 100%
rename from src/test/java/org/example/EbeanServerFactoryBean.java
rename to ebean-spring-txn/src/test/java/org/example/EbeanServerFactoryBean.java
diff --git a/src/test/java/org/example/EbeanSpringModuleTest.java b/ebean-spring-txn/src/test/java/org/example/EbeanSpringModuleTest.java
similarity index 100%
rename from src/test/java/org/example/EbeanSpringModuleTest.java
rename to ebean-spring-txn/src/test/java/org/example/EbeanSpringModuleTest.java
diff --git a/src/test/java/org/example/Role.java b/ebean-spring-txn/src/test/java/org/example/Role.java
similarity index 100%
rename from src/test/java/org/example/Role.java
rename to ebean-spring-txn/src/test/java/org/example/Role.java
diff --git a/src/test/java/org/example/User.java b/ebean-spring-txn/src/test/java/org/example/User.java
similarity index 100%
rename from src/test/java/org/example/User.java
rename to ebean-spring-txn/src/test/java/org/example/User.java
diff --git a/src/test/java/org/example/UserService.java b/ebean-spring-txn/src/test/java/org/example/UserService.java
similarity index 100%
rename from src/test/java/org/example/UserService.java
rename to ebean-spring-txn/src/test/java/org/example/UserService.java
diff --git a/src/test/java/org/example/UserServiceImpl.java b/ebean-spring-txn/src/test/java/org/example/UserServiceImpl.java
similarity index 100%
rename from src/test/java/org/example/UserServiceImpl.java
rename to ebean-spring-txn/src/test/java/org/example/UserServiceImpl.java
diff --git a/src/test/resources/default-ebean-server.xml b/ebean-spring-txn/src/test/resources/default-ebean-server.xml
similarity index 100%
rename from src/test/resources/default-ebean-server.xml
rename to ebean-spring-txn/src/test/resources/default-ebean-server.xml
diff --git a/src/test/resources/init-database.xml b/ebean-spring-txn/src/test/resources/init-database.xml
similarity index 100%
rename from src/test/resources/init-database.xml
rename to ebean-spring-txn/src/test/resources/init-database.xml
diff --git a/src/test/resources/logback-test.xml b/ebean-spring-txn/src/test/resources/logback-test.xml
similarity index 100%
rename from src/test/resources/logback-test.xml
rename to ebean-spring-txn/src/test/resources/logback-test.xml