From 1665b4f2fa6008c023c9902fdcf72ad44cc81331 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 13 Sep 2012 05:59:29 -0700 Subject: [PATCH 001/116] Initial commit --- README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 000000000..e9f3b4c45 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +avaje-ebeanorm-spring +===================== + +Spring integration with EbeanORM \ No newline at end of file From 6d8a9236f857ee485d4ac8c0e880324f703bf545 Mon Sep 17 00:00:00 2001 From: rbygrave <=> Date: Fri, 14 Sep 2012 01:06:56 +1200 Subject: [PATCH 002/116] initial add of EbeanORM spring from v2.8.1 --- .gitignore | 6 + pom.xml | 130 ++++++++++ src/main/java/META-INF/MANIFEST.MF | 3 + .../factory/EbeanServerFactoryBean.java | 85 +++++++ .../SpringAwareJdbcTransactionManager.java | 232 ++++++++++++++++++ .../txn/SpringJdbcTransaction.java | 45 ++++ src/main/resources/default-ebean-server.xml | 29 +++ .../avaje/ebean/springsupport/Account.java | 77 ++++++ .../springsupport/EbeanSpringModuleTest.java | 98 ++++++++ .../com/avaje/ebean/springsupport/Role.java | 73 ++++++ .../com/avaje/ebean/springsupport/User.java | 105 ++++++++ .../ebean/springsupport/UserService.java | 31 +++ .../ebean/springsupport/UserServiceImpl.java | 74 ++++++ src/test/resources/init-database.xml | 51 ++++ src/test/resources/jndi.properties | 1 + src/test/resources/jndi.xml | 25 ++ 16 files changed, 1065 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 src/main/java/META-INF/MANIFEST.MF create mode 100644 src/main/java/com/avaje/ebean/springsupport/factory/EbeanServerFactoryBean.java create mode 100644 src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java create mode 100644 src/main/java/com/avaje/ebean/springsupport/txn/SpringJdbcTransaction.java create mode 100644 src/main/resources/default-ebean-server.xml create mode 100644 src/test/java/com/avaje/ebean/springsupport/Account.java create mode 100644 src/test/java/com/avaje/ebean/springsupport/EbeanSpringModuleTest.java create mode 100644 src/test/java/com/avaje/ebean/springsupport/Role.java create mode 100644 src/test/java/com/avaje/ebean/springsupport/User.java create mode 100644 src/test/java/com/avaje/ebean/springsupport/UserService.java create mode 100644 src/test/java/com/avaje/ebean/springsupport/UserServiceImpl.java create mode 100644 src/test/resources/init-database.xml create mode 100644 src/test/resources/jndi.properties create mode 100644 src/test/resources/jndi.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..77344b780 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.sql +.classpath +.project +.settings/ +target/ +logs/ diff --git a/pom.xml b/pom.xml new file mode 100644 index 000000000..f6c0213af --- /dev/null +++ b/pom.xml @@ -0,0 +1,130 @@ + + + 4.0.0 + + org.avaje + avaje-javaparent + 1.1 + + + org.avaje.ebeanorm + avaje-ebeanorm-spring + avaje-ebeanorm-spring + 3.1.1-SNAPSHOT + jar + Support for Spring transactions and IOC setup of Ebean server config + + + UTF-8 + 3.0.0.RELEASE + 3.1.1 + + + http://www.avaje.org + + + + LGPL version 2.1 or later + http://www.gnu.org/licenses/lgpl-2.1.txt + repo + + + + + scm:git:https://github.com/rbygrave/avaje-ebeanorm-spring.git + scm:git:https://github.com/rbygrave/avaje-ebeanorm-spring.git + https://github.com/rbygrave/avaje-ebeanorm-spring.git + + + + + javax.persistence + persistence-api + 1.0 + + + org.avaje + ebean + ${ebean.version} + + + + + org.springframework + spring-core + ${spring.framework.version} + provided + + + org.springframework + spring-aspects + ${spring.framework.version} + provided + + + org.springframework + spring-jdbc + ${spring.framework.version} + provided + + + + + org.springframework + spring-test + ${spring.framework.version} + test + + + + junit + junit + 4.8.2 + test + + + + org.apache.xbean + xbean-spring + 3.5 + test + + + + com.h2database + h2 + 1.2.128 + test + + + + org.scala-lang + scala-library + 2.10.0-M6 + provided + + + + + + + org.avaje.ebeanorm + avaje-ebeanorm-mavenenhancer + ${ebean.version} + + + main + process-test-classes + + com.avaje.ebean.** + debug=1 + + + enhance + + + + + + + diff --git a/src/main/java/META-INF/MANIFEST.MF b/src/main/java/META-INF/MANIFEST.MF new file mode 100644 index 000000000..254272e1c --- /dev/null +++ b/src/main/java/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/src/main/java/com/avaje/ebean/springsupport/factory/EbeanServerFactoryBean.java b/src/main/java/com/avaje/ebean/springsupport/factory/EbeanServerFactoryBean.java new file mode 100644 index 000000000..a1daaeb6e --- /dev/null +++ b/src/main/java/com/avaje/ebean/springsupport/factory/EbeanServerFactoryBean.java @@ -0,0 +1,85 @@ +/** + * 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 com.avaje.ebean.springsupport.factory; + +import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.InitializingBean; + +import com.avaje.ebean.EbeanServer; +import com.avaje.ebean.EbeanServerFactory; +import com.avaje.ebean.config.ServerConfig; + +/** + * A Spring FactoryBean for constructing EbeanServer instances. + * + * @since 18.05.2009 + * @author E Mc Greal + */ +public class EbeanServerFactoryBean implements InitializingBean, FactoryBean { + + /** + * The Ebean server configuration. + */ + private ServerConfig serverConfig; + + /** + * The EbeanServer instance. + */ + private EbeanServer ebeanServer; + + public void afterPropertiesSet() throws Exception { + + if (serverConfig == null){ + throw new Exception("No ServerConig set. You must define a ServerConfig bean"); + } + + // Create the new EbeanServer using the configuration + this.ebeanServer = EbeanServerFactory.create(serverConfig); + } + + public EbeanServer getObject() throws Exception { + return ebeanServer; + } + + public Class getObjectType() { + return EbeanServer.class; + } + + /** + * Returns true for EbeanServer. + */ + public boolean isSingleton() { + return true; + } + + /** + * Return the server configuration. + */ + public ServerConfig getServerConfig() { + return serverConfig; + } + + /** + * Set the server configuration. + */ + public void setServerConfig(ServerConfig serverConfig) { + this.serverConfig = serverConfig; + } +} diff --git a/src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java b/src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java new file mode 100644 index 000000000..0fb7ac0b0 --- /dev/null +++ b/src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java @@ -0,0 +1,232 @@ +/** + * 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 com.avaje.ebean.springsupport.txn; + +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.persistence.PersistenceException; +import javax.sql.DataSource; + +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 com.avaje.ebean.config.ExternalTransactionManager; +import com.avaje.ebeaninternal.api.SpiTransaction; +import com.avaje.ebeaninternal.server.transaction.DefaultTransactionThreadLocal; +import com.avaje.ebeaninternal.server.transaction.TransactionManager; + +/** + * A Spring aware TransactionScopeManager. + * + *

+ * Will look for Spring transactions and use them if they exist. + *

+ * + * @since 18.05.2009 + * @author E Mc Greal + */ +public class SpringAwareJdbcTransactionManager implements ExternalTransactionManager { + + private final static Logger logger = Logger.getLogger(SpringAwareJdbcTransactionManager.class.getName()); + + /** + * The data source. + */ + private DataSource dataSource; + + /** + * The Ebean transaction manager. + */ + private TransactionManager transactionManager; + + /** + * The EbeanServer name. + */ + private String serverName; + + /** + * Instantiates a new spring aware transaction scope manager. + */ + public SpringAwareJdbcTransactionManager() { + } + + /** + * Initialise this with the Ebean internal transaction manager. + */ + public void setTransactionManager(Object txnMgr) { + + // RB: At this stage not exposing TransactionManager to + // the public API and hence the Object type and casting here + + this.transactionManager = (TransactionManager) txnMgr; + this.dataSource = transactionManager.getDataSource(); + this.serverName = transactionManager.getServerName(); + } + + /** + * 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). + *

+ */ + 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 = DefaultTransactionThreadLocal.get(serverName); + if (currentEbeanTransaction != null){ + // NOT expecting this so log WARNING + String msg = "SpringTransaction - no current spring txn BUT using current Ebean one "+currentEbeanTransaction.getId(); + logger.log(Level.WARNING, msg); + + } else if (logger.isLoggable(Level.FINEST)) { + logger.log(Level.FINEST, "Spring Txn - no current transaction "); + } + return currentEbeanTransaction; + } + + SpringTxnListener springTxnLister = getSpringTxnListener(); + + if (springTxnLister != null){ + // we have already seen this transaction + return springTxnLister.getTransaction(); + + } 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); + TransactionSynchronizationManager.registerSynchronization(springTxnLister); + + // also put in Ebean ThreadLocal + DefaultTransactionThreadLocal.set(serverName, newTrans); + return newTrans; + } + } + + /** + * Search for our specific transaction listener. + *

+ * If it exists then we have already seen and "wrapped" this transaction. + *

+ */ + private SpringTxnListener getSpringTxnListener() { + + if (TransactionSynchronizationManager.isSynchronizationActive()){ + 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); + } + } + } + } + + return null; + } + + /** + * 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. + *

+ */ + private SpringTxnListener createSpringTxnListener(SpringJdbcTransaction t) { + return new SpringTxnListener(transactionManager, t); + } + + /** + * 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. + *

+ */ + private static class SpringTxnListener extends TransactionSynchronizationAdapter { + + private final TransactionManager transactionManager; + + private final SpringJdbcTransaction transaction; + + private final String serverName; + + private SpringTxnListener(TransactionManager transactionManager, SpringJdbcTransaction t){ + this.transactionManager = transactionManager; + this.transaction = t; + this.serverName = transactionManager.getServerName(); + } + + /** + * Return the associated Ebean wrapped transaction. + */ + public SpringJdbcTransaction getTransaction() { + return transaction; + } + + @Override + public void beforeCommit(boolean readOnly) { + // Future note: for JPA2 locking we will + // have beforeCommit events to fire + } + + @Override + public void afterCompletion(int status) { + + switch (status) { + case STATUS_COMMITTED: + if (logger.isLoggable(Level.FINE)){ + logger.fine("Spring Txn ["+transaction.getId()+"] committed"); + } + transactionManager.notifyOfCommit(transaction); + break; + + case STATUS_ROLLED_BACK: + if (logger.isLoggable(Level.FINE)){ + logger.fine("Spring Txn ["+transaction.getId()+"] rollback"); + } + transactionManager.notifyOfRollback(transaction, null); + break; + + default: + // this should never happen + String msg = "Invalid status "+status; + throw new PersistenceException(msg); + } + + // Remove this transaction object as it is completed + DefaultTransactionThreadLocal.replace(serverName, null); + } + } +} diff --git a/src/main/java/com/avaje/ebean/springsupport/txn/SpringJdbcTransaction.java b/src/main/java/com/avaje/ebean/springsupport/txn/SpringJdbcTransaction.java new file mode 100644 index 000000000..367e0f6bb --- /dev/null +++ b/src/main/java/com/avaje/ebean/springsupport/txn/SpringJdbcTransaction.java @@ -0,0 +1,45 @@ +/** + * 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 com.avaje.ebean.springsupport.txn; + +import org.springframework.jdbc.datasource.ConnectionHolder; + +import com.avaje.ebeaninternal.server.transaction.ExternalJdbcTransaction; +import com.avaje.ebeaninternal.server.transaction.TransactionManager; + +public class SpringJdbcTransaction extends ExternalJdbcTransaction { + + private final ConnectionHolder holder; + + public SpringJdbcTransaction(ConnectionHolder holder, TransactionManager manager) { + super("s"+holder.hashCode(), true, holder.getConnection(), manager); + this.holder = holder; + } + + @Override + public boolean isActive() { + return holder.isSynchronizedWithTransaction(); + } + + public ConnectionHolder getConnectionHolder() { + return holder; + } +} diff --git a/src/main/resources/default-ebean-server.xml b/src/main/resources/default-ebean-server.xml new file mode 100644 index 000000000..8245aa32e --- /dev/null +++ b/src/main/resources/default-ebean-server.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/com/avaje/ebean/springsupport/Account.java b/src/test/java/com/avaje/ebean/springsupport/Account.java new file mode 100644 index 000000000..d898a476b --- /dev/null +++ b/src/test/java/com/avaje/ebean/springsupport/Account.java @@ -0,0 +1,77 @@ +/** + * 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 com.avaje.ebean.springsupport; + +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 oid. */ + @Id + private long oid; + + /** The user. */ + @OneToOne + private User user; + + /** + * Gets the oid. + * + * @return the oid + */ + public long getOid() { + return oid; + } + + /** + * Sets the oid. + * + * @param oid the oid to set + */ + public void setOid(long oid) { + this.oid = oid; + } + + /** + * Gets the user. + * + * @return the user + */ + public User getUser() { + return user; + } + + /** + * Sets the user. + * + * @param user the user to set + */ + public void setUser(User user) { + this.user = user; + } +} diff --git a/src/test/java/com/avaje/ebean/springsupport/EbeanSpringModuleTest.java b/src/test/java/com/avaje/ebean/springsupport/EbeanSpringModuleTest.java new file mode 100644 index 000000000..866a02b55 --- /dev/null +++ b/src/test/java/com/avaje/ebean/springsupport/EbeanSpringModuleTest.java @@ -0,0 +1,98 @@ +/** + * 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 com.avaje.ebean.springsupport; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.logging.Logger; + +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; + +/** + * Unit test for Ebean Spring Module. + * @since 18.05.2009 + * @author E Mc Greal + */ +@ContextConfiguration(locations={"/init-database.xml"}) +public class EbeanSpringModuleTest extends AbstractJUnit4SpringContextTests { + + /** The Constant logger. */ + private final static Logger logger = Logger.getLogger(EbeanSpringModuleTest.class.getName()); + + /** The user service. */ + @Autowired + private UserService userService; + + /** + * Create the test case. + */ + public EbeanSpringModuleTest(){ + super(); + } + + + /** + * Test app. + */ + @Test + public void testSaveUser(){ + logger.info("Saving new User..."); + User user = new User(); + user.setName("ebean"); + userService.save(user); + logger.info("Saved new User"); + } + + /** + * Test app. + */ + @Test + public void testFindUser(){ + logger.info("Finding User with OID = 1 ..."); + User user = userService.find(1); + + assertNotNull(user); + assertTrue("ebean".equals(user.getName())); + logger.info("Found User with OID = 1"); + } + + /** + * Gets the user service. + * + * @return the userService + */ + public UserService getUserService() { + return userService; + } + + + /** + * Sets the user service. + * + * @param userService the userService to set + */ + public void setUserService(UserService userService) { + this.userService = userService; + } +} diff --git a/src/test/java/com/avaje/ebean/springsupport/Role.java b/src/test/java/com/avaje/ebean/springsupport/Role.java new file mode 100644 index 000000000..99adbf370 --- /dev/null +++ b/src/test/java/com/avaje/ebean/springsupport/Role.java @@ -0,0 +1,73 @@ +/** + * 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 com.avaje.ebean.springsupport; + +import java.util.HashSet; +import java.util.Set; + +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 { + @Id + long oid; + + @ManyToMany + private Set users = new HashSet(); + + /** + * @return the oid + */ + public long getOid() { + return oid; + } + + /** + * @param oid the oid to set + */ + public void setOid(long oid) { + this.oid = oid; + } + + /** + * @return the users + */ + public Set getUsers() { + return users; + } + + /** + * @param users the users to set + */ + public void setUsers(Set users) { + this.users = users; + } + + + +} diff --git a/src/test/java/com/avaje/ebean/springsupport/User.java b/src/test/java/com/avaje/ebean/springsupport/User.java new file mode 100644 index 000000000..6a4a54316 --- /dev/null +++ b/src/test/java/com/avaje/ebean/springsupport/User.java @@ -0,0 +1,105 @@ +/** + * 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 com.avaje.ebean.springsupport; + +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToMany; +import javax.persistence.OneToOne; + +/** + * The Class User. + * @since 18.05.2009 + * @author E Mc Greal + */ +@Entity +public class User { + @Id + long oid; + + private String name; + + @ManyToMany + private Set roles = new HashSet(); + + @OneToOne(mappedBy="user") + private Account account; + + /** + * @return the oid + */ + public long getOid() { + return oid; + } + + /** + * @param oid the oid to set + */ + public void setOid(long oid) { + this.oid = oid; + } + + /** + * @return the roles + */ + public Set getRoles() { + return roles; + } + + /** + * @param roles the roles to set + */ + public void setRoles(Set roles) { + this.roles = roles; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the account + */ + public Account getAccount() { + return account; + } + + /** + * @param account the account to set + */ + public void setAccount(Account account) { + this.account = account; + } + +} diff --git a/src/test/java/com/avaje/ebean/springsupport/UserService.java b/src/test/java/com/avaje/ebean/springsupport/UserService.java new file mode 100644 index 000000000..7375386ae --- /dev/null +++ b/src/test/java/com/avaje/ebean/springsupport/UserService.java @@ -0,0 +1,31 @@ +/** + * 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 com.avaje.ebean.springsupport; + +/** + * The Interface UserService. + * @since 18.05.2009 + * @author E Mc Greal + */ +public interface UserService { + public void save(User user); + public User find(long oid); +} diff --git a/src/test/java/com/avaje/ebean/springsupport/UserServiceImpl.java b/src/test/java/com/avaje/ebean/springsupport/UserServiceImpl.java new file mode 100644 index 000000000..65f844d72 --- /dev/null +++ b/src/test/java/com/avaje/ebean/springsupport/UserServiceImpl.java @@ -0,0 +1,74 @@ +/** + * 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 com.avaje.ebean.springsupport; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import com.avaje.ebean.EbeanServer; + +/** + * The Class UserServiceImpl. + * + * @since 18.05.2009 + * @author E Mc Greal + */ +public class UserServiceImpl implements UserService { + + /** The ebean server. */ + @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) + public void save(User user) { + ebeanServer.save(user); + } + + @Transactional(readOnly = true, propagation = Propagation.REQUIRED) + public User find(long oid) { + return ebeanServer.find(User.class, oid); + } + + + /** + * Gets the ebean server. + * + * @return the ebeanServer + */ + public EbeanServer getEbeanServer() { + return ebeanServer; + } + + /** + * Sets the ebean server. + * + * @param ebeanServer the ebeanServer to set + */ + public void setEbeanServer(EbeanServer ebeanServer) { + this.ebeanServer = ebeanServer; + } + + +} diff --git a/src/test/resources/init-database.xml b/src/test/resources/init-database.xml new file mode 100644 index 000000000..a91ec58c8 --- /dev/null +++ b/src/test/resources/init-database.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + com.avaje.ebean.springsupport.User + com.avaje.ebean.springsupport.Role + com.avaje.ebean.springsupport.Account + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/jndi.properties b/src/test/resources/jndi.properties new file mode 100644 index 000000000..a954f4c9c --- /dev/null +++ b/src/test/resources/jndi.properties @@ -0,0 +1 @@ +java.naming.factory.initial = org.apache.xbean.spring.jndi.SpringInitialContextFactory diff --git a/src/test/resources/jndi.xml b/src/test/resources/jndi.xml new file mode 100644 index 000000000..f7af2db77 --- /dev/null +++ b/src/test/resources/jndi.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From d64073bef000d4024996af868c1f4fc0e38cf36c Mon Sep 17 00:00:00 2001 From: rbygrave <=> Date: Sat, 15 Sep 2012 01:15:37 +1200 Subject: [PATCH 003/116] Change license to Apache2, clean up dependencies --- pom.xml | 251 +++++++++++++++++++++++++++----------------------------- 1 file changed, 121 insertions(+), 130 deletions(-) diff --git a/pom.xml b/pom.xml index f6c0213af..67b697d48 100644 --- a/pom.xml +++ b/pom.xml @@ -1,130 +1,121 @@ - - - 4.0.0 - - org.avaje - avaje-javaparent - 1.1 - - - org.avaje.ebeanorm - avaje-ebeanorm-spring - avaje-ebeanorm-spring - 3.1.1-SNAPSHOT - jar - Support for Spring transactions and IOC setup of Ebean server config - - - UTF-8 - 3.0.0.RELEASE - 3.1.1 - - - http://www.avaje.org - - - - LGPL version 2.1 or later - http://www.gnu.org/licenses/lgpl-2.1.txt - repo - - - - - scm:git:https://github.com/rbygrave/avaje-ebeanorm-spring.git - scm:git:https://github.com/rbygrave/avaje-ebeanorm-spring.git - https://github.com/rbygrave/avaje-ebeanorm-spring.git - - - - - javax.persistence - persistence-api - 1.0 - - - org.avaje - ebean - ${ebean.version} - - - - - org.springframework - spring-core - ${spring.framework.version} - provided - - - org.springframework - spring-aspects - ${spring.framework.version} - provided - - - org.springframework - spring-jdbc - ${spring.framework.version} - provided - - - - - org.springframework - spring-test - ${spring.framework.version} - test - - - - junit - junit - 4.8.2 - test - - - - org.apache.xbean - xbean-spring - 3.5 - test - - - - com.h2database - h2 - 1.2.128 - test - - - - org.scala-lang - scala-library - 2.10.0-M6 - provided - - - - - - - org.avaje.ebeanorm - avaje-ebeanorm-mavenenhancer - ${ebean.version} - - - main - process-test-classes - - com.avaje.ebean.** - debug=1 - - - enhance - - - - - - - + + + 4.0.0 + + org.avaje + avaje-javaparent + 1.1 + + + org.avaje.ebeanorm + avaje-ebeanorm-spring + avaje-ebeanorm-spring + 3.1.1-SNAPSHOT + jar + Support for Spring transactions and IOC setup of Ebean server config + + + UTF-8 + 3.0.0.RELEASE + 3.1.1 + + + http://www.avaje.org + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + scm:git:https://github.com/rbygrave/avaje-ebeanorm-spring.git + scm:git:https://github.com/rbygrave/avaje-ebeanorm-spring.git + https://github.com/rbygrave/avaje-ebeanorm-spring.git + + + + + + org.avaje.ebeanorm + avaje-ebeanorm + [3,4) + + + + + org.springframework + spring-core + ${spring.framework.version} + provided + + + org.springframework + spring-aspects + ${spring.framework.version} + provided + + + org.springframework + spring-jdbc + ${spring.framework.version} + provided + + + + + org.springframework + spring-test + ${spring.framework.version} + test + + + + junit + junit + 4.8.2 + test + + + + org.apache.xbean + xbean-spring + 3.5 + test + + + + com.h2database + h2 + 1.2.128 + test + + + + + + + + org.avaje.ebeanorm + avaje-ebeanorm-mavenenhancer + ${ebean.mavenenhancer.version} + + + main + process-test-classes + + com.avaje.ebean.** + debug=1 + + + enhance + + + + + + + From 4a6b58bd9b7c2ce0354b4354dd22c03cf2b496a0 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Sat, 15 Sep 2012 01:30:21 +1200 Subject: [PATCH 004/116] Remove commons logging from dependency --- pom.xml | 279 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 158 insertions(+), 121 deletions(-) diff --git a/pom.xml b/pom.xml index 67b697d48..8eedd9fea 100644 --- a/pom.xml +++ b/pom.xml @@ -1,121 +1,158 @@ - - - 4.0.0 - - org.avaje - avaje-javaparent - 1.1 - - - org.avaje.ebeanorm - avaje-ebeanorm-spring - avaje-ebeanorm-spring - 3.1.1-SNAPSHOT - jar - Support for Spring transactions and IOC setup of Ebean server config - - - UTF-8 - 3.0.0.RELEASE - 3.1.1 - - - http://www.avaje.org - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - scm:git:https://github.com/rbygrave/avaje-ebeanorm-spring.git - scm:git:https://github.com/rbygrave/avaje-ebeanorm-spring.git - https://github.com/rbygrave/avaje-ebeanorm-spring.git - - - - - - org.avaje.ebeanorm - avaje-ebeanorm - [3,4) - - - - - org.springframework - spring-core - ${spring.framework.version} - provided - - - org.springframework - spring-aspects - ${spring.framework.version} - provided - - - org.springframework - spring-jdbc - ${spring.framework.version} - provided - - - - - org.springframework - spring-test - ${spring.framework.version} - test - - - - junit - junit - 4.8.2 - test - - - - org.apache.xbean - xbean-spring - 3.5 - test - - - - com.h2database - h2 - 1.2.128 - test - - - - - - - - org.avaje.ebeanorm - avaje-ebeanorm-mavenenhancer - ${ebean.mavenenhancer.version} - - - main - process-test-classes - - com.avaje.ebean.** - debug=1 - - - enhance - - - - - - - + + + 4.0.0 + + org.avaje + avaje-javaparent + 1.1 + + + org.avaje.ebeanorm + avaje-ebeanorm-spring + avaje-ebeanorm-spring + 3.1.1-SNAPSHOT + jar + Support for Spring transactions and IOC setup of Ebean server config + + + UTF-8 + 3.0.0.RELEASE + 3.1.1 + + + http://www.avaje.org + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + scm:git:https://github.com/rbygrave/avaje-ebeanorm-spring.git + scm:git:https://github.com/rbygrave/avaje-ebeanorm-spring.git + https://github.com/rbygrave/avaje-ebeanorm-spring.git + + + + + + org.avaje.ebeanorm + avaje-ebeanorm + [3,4) + + + + + org.springframework + spring-core + ${spring.framework.version} + provided + + + commons-logging + commons-logging + + + + + org.springframework + spring-aspects + ${spring.framework.version} + provided + + + commons-logging + commons-logging + + + + + org.springframework + spring-jdbc + ${spring.framework.version} + provided + + + commons-logging + commons-logging + + + + + + + org.springframework + spring-test + ${spring.framework.version} + test + + + commons-logging + commons-logging + + + + + + org.slf4j + jcl-over-slf4j + [1.6.2] + + + + junit + junit + 4.8.2 + test + + + + org.apache.xbean + xbean-spring + 3.5 + test + + + commons-logging + commons-logging + + + + + + com.h2database + h2 + 1.2.128 + test + + + + + + + + org.avaje.ebeanorm + avaje-ebeanorm-mavenenhancer + ${ebean.mavenenhancer.version} + + + main + process-test-classes + + target/test-classes + com.avaje.ebean.** + debug=9 + + + enhance + + + + + + + From 1d570a233ef5a317352e85a07521dfef55e68c34 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Sat, 15 Sep 2012 01:31:49 +1200 Subject: [PATCH 005/116] [maven-release-plugin] prepare release avaje-ebeanorm-spring-3.1.1 --- pom.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 8eedd9fea..4e1a51eef 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,5 @@ - + 4.0.0 org.avaje @@ -11,7 +10,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 3.1.1-SNAPSHOT + 3.1.1 jar Support for Spring transactions and IOC setup of Ebean server config From 782f77b6887994a2a80b3452585efae0d0997e44 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Sat, 15 Sep 2012 01:32:05 +1200 Subject: [PATCH 006/116] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4e1a51eef..82fe6cf23 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 3.1.1 + 3.1.2-SNAPSHOT jar Support for Spring transactions and IOC setup of Ebean server config From 5df3ac4b0460cedc8271513cf81b91997ab12f9a Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Mon, 29 Apr 2013 21:13:37 +1200 Subject: [PATCH 007/116] Change package of test beans etc for enhancement --- pom.xml | 23 ++++++++++++------- .../springsupport/Account.java | 2 +- .../springsupport/EbeanSpringModuleTest.java | 2 +- .../{ebean => test}/springsupport/Role.java | 2 +- .../{ebean => test}/springsupport/User.java | 2 +- .../springsupport/UserService.java | 2 +- .../springsupport/UserServiceImpl.java | 2 +- src/test/resources/init-database.xml | 8 +++---- 8 files changed, 25 insertions(+), 18 deletions(-) rename src/test/java/com/avaje/{ebean => test}/springsupport/Account.java (97%) rename src/test/java/com/avaje/{ebean => test}/springsupport/EbeanSpringModuleTest.java (98%) rename src/test/java/com/avaje/{ebean => test}/springsupport/Role.java (97%) rename src/test/java/com/avaje/{ebean => test}/springsupport/User.java (98%) rename src/test/java/com/avaje/{ebean => test}/springsupport/UserService.java (96%) rename src/test/java/com/avaje/{ebean => test}/springsupport/UserServiceImpl.java (98%) diff --git a/pom.xml b/pom.xml index 82fe6cf23..7e4a74102 100644 --- a/pom.xml +++ b/pom.xml @@ -4,20 +4,20 @@ org.avaje avaje-javaparent - 1.1 + 1.2 org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 3.1.2-SNAPSHOT + 3.2.1-SNAPSHOT jar Support for Spring transactions and IOC setup of Ebean server config UTF-8 3.0.0.RELEASE - 3.1.1 + 3.2.1 http://www.avaje.org @@ -31,9 +31,9 @@ - scm:git:https://github.com/rbygrave/avaje-ebeanorm-spring.git - scm:git:https://github.com/rbygrave/avaje-ebeanorm-spring.git - https://github.com/rbygrave/avaje-ebeanorm-spring.git + scm:git:https://github.com/avaje-ebeanorm/avaje-ebeanorm-spring.git + scm:git:https://github.com/avaje-ebeanorm/avaje-ebeanorm-spring.git + https://github.com/avaje-ebeanorm/avaje-ebeanorm-spring.git @@ -41,7 +41,14 @@ org.avaje.ebeanorm avaje-ebeanorm - [3,4) + [3.2,4) + + + + org.avaje.ebeanorm + avaje-ebeanorm-agent + 3.2.1 + test @@ -143,7 +150,7 @@ process-test-classes target/test-classes - com.avaje.ebean.** + com.avaje.** debug=9 diff --git a/src/test/java/com/avaje/ebean/springsupport/Account.java b/src/test/java/com/avaje/test/springsupport/Account.java similarity index 97% rename from src/test/java/com/avaje/ebean/springsupport/Account.java rename to src/test/java/com/avaje/test/springsupport/Account.java index d898a476b..a527e9652 100644 --- a/src/test/java/com/avaje/ebean/springsupport/Account.java +++ b/src/test/java/com/avaje/test/springsupport/Account.java @@ -17,7 +17,7 @@ * along with Ebean; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -package com.avaje.ebean.springsupport; +package com.avaje.test.springsupport; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/src/test/java/com/avaje/ebean/springsupport/EbeanSpringModuleTest.java b/src/test/java/com/avaje/test/springsupport/EbeanSpringModuleTest.java similarity index 98% rename from src/test/java/com/avaje/ebean/springsupport/EbeanSpringModuleTest.java rename to src/test/java/com/avaje/test/springsupport/EbeanSpringModuleTest.java index 866a02b55..2eecfd646 100644 --- a/src/test/java/com/avaje/ebean/springsupport/EbeanSpringModuleTest.java +++ b/src/test/java/com/avaje/test/springsupport/EbeanSpringModuleTest.java @@ -17,7 +17,7 @@ * along with Ebean; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -package com.avaje.ebean.springsupport; +package com.avaje.test.springsupport; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; diff --git a/src/test/java/com/avaje/ebean/springsupport/Role.java b/src/test/java/com/avaje/test/springsupport/Role.java similarity index 97% rename from src/test/java/com/avaje/ebean/springsupport/Role.java rename to src/test/java/com/avaje/test/springsupport/Role.java index 99adbf370..e6fed39d2 100644 --- a/src/test/java/com/avaje/ebean/springsupport/Role.java +++ b/src/test/java/com/avaje/test/springsupport/Role.java @@ -18,7 +18,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -package com.avaje.ebean.springsupport; +package com.avaje.test.springsupport; import java.util.HashSet; import java.util.Set; diff --git a/src/test/java/com/avaje/ebean/springsupport/User.java b/src/test/java/com/avaje/test/springsupport/User.java similarity index 98% rename from src/test/java/com/avaje/ebean/springsupport/User.java rename to src/test/java/com/avaje/test/springsupport/User.java index 6a4a54316..430d777b7 100644 --- a/src/test/java/com/avaje/ebean/springsupport/User.java +++ b/src/test/java/com/avaje/test/springsupport/User.java @@ -18,7 +18,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -package com.avaje.ebean.springsupport; +package com.avaje.test.springsupport; import java.util.HashSet; import java.util.Set; diff --git a/src/test/java/com/avaje/ebean/springsupport/UserService.java b/src/test/java/com/avaje/test/springsupport/UserService.java similarity index 96% rename from src/test/java/com/avaje/ebean/springsupport/UserService.java rename to src/test/java/com/avaje/test/springsupport/UserService.java index 7375386ae..072824263 100644 --- a/src/test/java/com/avaje/ebean/springsupport/UserService.java +++ b/src/test/java/com/avaje/test/springsupport/UserService.java @@ -18,7 +18,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -package com.avaje.ebean.springsupport; +package com.avaje.test.springsupport; /** * The Interface UserService. diff --git a/src/test/java/com/avaje/ebean/springsupport/UserServiceImpl.java b/src/test/java/com/avaje/test/springsupport/UserServiceImpl.java similarity index 98% rename from src/test/java/com/avaje/ebean/springsupport/UserServiceImpl.java rename to src/test/java/com/avaje/test/springsupport/UserServiceImpl.java index 65f844d72..eab077042 100644 --- a/src/test/java/com/avaje/ebean/springsupport/UserServiceImpl.java +++ b/src/test/java/com/avaje/test/springsupport/UserServiceImpl.java @@ -18,7 +18,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -package com.avaje.ebean.springsupport; +package com.avaje.test.springsupport; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Propagation; diff --git a/src/test/resources/init-database.xml b/src/test/resources/init-database.xml index a91ec58c8..220ba5051 100644 --- a/src/test/resources/init-database.xml +++ b/src/test/resources/init-database.xml @@ -29,9 +29,9 @@ - com.avaje.ebean.springsupport.User - com.avaje.ebean.springsupport.Role - com.avaje.ebean.springsupport.Account + com.avaje.test.springsupport.User + com.avaje.test.springsupport.Role + com.avaje.test.springsupport.Account @@ -45,7 +45,7 @@ - + From 199a9d3118bab52d9dc3518af4cd40a3654bd1ae Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Mon, 29 Apr 2013 21:26:37 +1200 Subject: [PATCH 008/116] Opps, fixed scm location --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 7e4a74102..30578359e 100644 --- a/pom.xml +++ b/pom.xml @@ -31,9 +31,9 @@ - scm:git:https://github.com/avaje-ebeanorm/avaje-ebeanorm-spring.git - scm:git:https://github.com/avaje-ebeanorm/avaje-ebeanorm-spring.git - https://github.com/avaje-ebeanorm/avaje-ebeanorm-spring.git + scm:git:https://github.com/ebean-orm/avaje-ebeanorm-spring.git + scm:git:https://github.com/ebean-orm/avaje-ebeanorm-spring.git + https://github.com/ebean-orm/avaje-ebeanorm-spring.git From a7d47202e6fffb94a0007892b0710cee616c391f Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Mon, 29 Apr 2013 21:27:19 +1200 Subject: [PATCH 009/116] [maven-release-plugin] prepare release avaje-ebeanorm-spring-3.2.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 30578359e..d789f8751 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 3.2.1-SNAPSHOT + 3.2.1 jar Support for Spring transactions and IOC setup of Ebean server config From 3b97f77083cc7b79e458e7451db7f96e6a78f7a9 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Mon, 29 Apr 2013 21:27:36 +1200 Subject: [PATCH 010/116] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d789f8751..209204877 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 3.2.1 + 3.2.2-SNAPSHOT jar Support for Spring transactions and IOC setup of Ebean server config From 035fb809598f2d21ecd939520f38f3867bf0677a Mon Sep 17 00:00:00 2001 From: Eddie Mc Greal Date: Thu, 6 Mar 2014 22:17:55 +0100 Subject: [PATCH 011/116] Changed to correct version and removed old logging config stuff --- pom.xml | 37 ++++++++++++++++++++- src/main/resources/default-ebean-server.xml | 4 --- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 209204877..bc63214c9 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 3.2.2-SNAPSHOT + 3.3.1-RC3-SNAPSHOT jar Support for Spring transactions and IOC setup of Ebean server config @@ -160,5 +160,40 @@ + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.avaje.ebeanorm + + + avaje-ebeanorm-mavenenhancer + + + [3.2.1,) + + + enhance + + + + + + + + + + + + diff --git a/src/main/resources/default-ebean-server.xml b/src/main/resources/default-ebean-server.xml index 8245aa32e..9dd031e65 100644 --- a/src/main/resources/default-ebean-server.xml +++ b/src/main/resources/default-ebean-server.xml @@ -14,10 +14,6 @@ - - - - From 6379bd9e5d07a08f971e971803bef8b5a73c5ca7 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Wed, 2 Apr 2014 22:12:31 +1300 Subject: [PATCH 012/116] Set pom to 3.3.1-SNAPSHOT, ready for release --- pom.xml | 84 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/pom.xml b/pom.xml index bc63214c9..537e54d82 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.avaje @@ -10,7 +11,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 3.3.1-RC3-SNAPSHOT + 3.3.1-SNAPSHOT jar Support for Spring transactions and IOC setup of Ebean server config @@ -43,7 +44,7 @@ avaje-ebeanorm [3.2,4) - + org.avaje.ebeanorm avaje-ebeanorm-agent @@ -61,7 +62,7 @@ commons-logging commons-logging - + @@ -73,7 +74,7 @@ commons-logging commons-logging - + @@ -85,7 +86,7 @@ commons-logging commons-logging - + @@ -99,7 +100,7 @@ commons-logging commons-logging - + @@ -125,7 +126,7 @@ commons-logging commons-logging - + @@ -161,39 +162,40 @@ - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - - org.avaje.ebeanorm - - - avaje-ebeanorm-mavenenhancer - - - [3.2.1,) - - - enhance - - - - - - - - - - - + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.avaje.ebeanorm + + + avaje-ebeanorm-mavenenhancer + + + [3.2.1,3.9) + + + enhance + + + + + + + + + + + From 6fbbd8b107d5bccf9eafc01b7840030a81b1f4fc Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Wed, 2 Apr 2014 22:15:25 +1300 Subject: [PATCH 013/116] [maven-release-plugin] prepare release avaje-ebeanorm-spring-3.3.1 --- pom.xml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 537e54d82..8f950c8ca 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,5 @@ - + 4.0.0 org.avaje @@ -11,7 +10,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 3.3.1-SNAPSHOT + 3.3.1 jar Support for Spring transactions and IOC setup of Ebean server config @@ -188,7 +187,7 @@ - + From 068401c29cc98b74bfd8c728641f3a4509cc6212 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Wed, 2 Apr 2014 22:15:51 +1300 Subject: [PATCH 014/116] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8f950c8ca..af3acd45d 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 3.3.1 + 3.3.2-SNAPSHOT jar Support for Spring transactions and IOC setup of Ebean server config From f18c24c1d12056ef0a0528fa1c46c7404321687b Mon Sep 17 00:00:00 2001 From: Eddie Mc Greal Date: Tue, 14 Oct 2014 08:11:32 +0200 Subject: [PATCH 015/116] Update Version to 4.1.9 and edited MANIFEST for OSGi --- pom.xml | 11 ++++++++++- src/main/resources/META-INF/MANIFEST.MF | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/META-INF/MANIFEST.MF diff --git a/pom.xml b/pom.xml index af3acd45d..778f08fcf 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 3.3.2-SNAPSHOT + 4.1.9-SNAPSHOT jar Support for Spring transactions and IOC setup of Ebean server config @@ -159,6 +159,15 @@ + + org.apache.maven.plugins + maven-jar-plugin + + + src/main/resources/META-INF/MANIFEST.MF + + + diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 000000000..e025373c1 --- /dev/null +++ b/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,18 @@ +Manifest-Version: 1.0 +Premain-Class: com.avaje.ebean.enhance.agent.Transformer +Bundle-ManifestVersion: 2 +Bundle-Name: Ebean-ORM-SPRING +Bundle-SymbolicName: com.avaje.ebean.springsupport +Bundle-Version: 4.1.9 +Bundle-ClassPath: . +Bundle-Vendor: avaje +Export-Package: com.avaje.ebean.springsupport.factory, + com.avaje.ebean.springsupport.txn +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Require-Bundle: com.avaje.ebean;bundle-version="4.1.9", + org.springframework.beans;bundle-version="3.1.0", + org.springframework.context;bundle-version="3.1.0", + org.slf4j.api;bundle-version="1.7.2" +Import-Package: javax.persistence;version="2.0.0" + + From a3df7919b51731addec6fb3bf4789023a6c4e719 Mon Sep 17 00:00:00 2001 From: Eddie Mc Greal Date: Tue, 20 Jan 2015 09:54:21 +0100 Subject: [PATCH 016/116] Updated to correct ebeanorm dependency range --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 778f08fcf..20b97d276 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 4.1.9-SNAPSHOT + 4.5.3-SNAPSHOT jar Support for Spring transactions and IOC setup of Ebean server config @@ -41,7 +41,7 @@ org.avaje.ebeanorm avaje-ebeanorm - [3.2,4) + [4,5) From 6d4b3ad84e70037f0e9f31c5928beb7a7b2b9de0 Mon Sep 17 00:00:00 2001 From: guor Date: Mon, 11 May 2015 21:01:58 +0800 Subject: [PATCH 017/116] Create AgentLoaderSupport.java add support for setup enhancement in spring --- .../springsupport/AgentLoaderSupport.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/main/java/com/avaje/ebean/springsupport/AgentLoaderSupport.java diff --git a/src/main/java/com/avaje/ebean/springsupport/AgentLoaderSupport.java b/src/main/java/com/avaje/ebean/springsupport/AgentLoaderSupport.java new file mode 100644 index 000000000..940177208 --- /dev/null +++ b/src/main/java/com/avaje/ebean/springsupport/AgentLoaderSupport.java @@ -0,0 +1,46 @@ +package com.avaje.ebean.springsupport; + +import org.avaje.agentloader.AgentLoader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.InitializingBean; + +/** + * To Setup Enhancement in Spring + * + * + * + * + * Created by guor on 2015/5/11. + */ +public class AgentLoaderSupport implements InitializingBean { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private int debug; + private String packages; + + public int getDebug() { + return debug; + } + + public void setDebug(int debug) { + this.debug = debug; + } + + public String getPackages() { + return packages; + } + + public void setPackages(String packages) { + this.packages = packages; + } + + @Override + public void afterPropertiesSet() throws Exception { + String args = "debug=" + getDebug() + ";packages=" + getPackages(); + if (!AgentLoader.loadAgentFromClasspath("avaje-ebeanorm-agent", args)) { + logger.info("avaje-ebeanorm-agent not found in classpath - not dynamically loaded"); + } + } +} From a83114ced29c08a006489da6e8e660b727e0e693 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 30 Jul 2015 04:53:25 +1200 Subject: [PATCH 018/116] Update tests and dependencies --- .gitignore | 3 + pom.xml | 53 ++++---- .../com/avaje/test/springsupport/Account.java | 64 ++++------ .../springsupport/EbeanSpringModuleTest.java | 115 +++++++++--------- .../com/avaje/test/springsupport/Role.java | 52 +++----- .../com/avaje/test/springsupport/User.java | 31 +---- .../avaje/test/springsupport/UserService.java | 8 +- .../test/springsupport/UserServiceImpl.java | 37 ++++-- src/test/resources/init-database.xml | 14 ++- src/test/resources/jndi.properties | 1 - src/test/resources/jndi.xml | 25 ---- 11 files changed, 174 insertions(+), 229 deletions(-) delete mode 100644 src/test/resources/jndi.properties delete mode 100644 src/test/resources/jndi.xml diff --git a/.gitignore b/.gitignore index 77344b780..2befb7af3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ .settings/ target/ logs/ +.idea/ +*.iml + diff --git a/pom.xml b/pom.xml index 20b97d276..55b07566f 100644 --- a/pom.xml +++ b/pom.xml @@ -16,8 +16,7 @@ UTF-8 - 3.0.0.RELEASE - 3.2.1 + 4.1.7.RELEASE http://www.avaje.org @@ -41,17 +40,28 @@ org.avaje.ebeanorm avaje-ebeanorm - [4,5) + [6,7) org.avaje.ebeanorm avaje-ebeanorm-agent - 3.2.1 - test + [4.5,5) + + + + org.avaje + avaje-agentloader + 2.1.2 + + org.springframework + spring-context + ${spring.framework.version} + + org.springframework spring-core @@ -106,33 +116,14 @@ org.slf4j jcl-over-slf4j - [1.6.2] + 1.7.12 - junit - junit - 4.8.2 - test - - - - org.apache.xbean - xbean-spring - 3.5 - test - - - commons-logging - commons-logging - - - - - - com.h2database - h2 - 1.2.128 + org.avaje.composite + avaje-composite-testing-ebean + 4.1 + pom test @@ -143,7 +134,7 @@ org.avaje.ebeanorm avaje-ebeanorm-mavenenhancer - ${ebean.mavenenhancer.version} + 4.5.3 main @@ -189,7 +180,7 @@ avaje-ebeanorm-mavenenhancer - [3.2.1,3.9) + [3,4) enhance diff --git a/src/test/java/com/avaje/test/springsupport/Account.java b/src/test/java/com/avaje/test/springsupport/Account.java index a527e9652..12043ed5d 100644 --- a/src/test/java/com/avaje/test/springsupport/Account.java +++ b/src/test/java/com/avaje/test/springsupport/Account.java @@ -1,18 +1,18 @@ /** * 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 @@ -31,47 +31,27 @@ import javax.persistence.OneToOne; @Entity public class Account { - /** The oid. */ - @Id - private long oid; + /** The id. */ + @Id + private Long id; - /** The user. */ - @OneToOne - private User user; + /** The user. */ + @OneToOne + private User user; - /** - * Gets the oid. - * - * @return the oid - */ - public long getOid() { - return oid; - } + public Long getId() { + return id; + } - /** - * Sets the oid. - * - * @param oid the oid to set - */ - public void setOid(long oid) { - this.oid = oid; - } + public void setId(Long id) { + this.id = id; + } - /** - * Gets the user. - * - * @return the user - */ - public User getUser() { - return user; - } + public User getUser() { + return user; + } - /** - * Sets the user. - * - * @param user the user to set - */ - public void setUser(User user) { - this.user = user; - } + public void setUser(User user) { + this.user = user; + } } diff --git a/src/test/java/com/avaje/test/springsupport/EbeanSpringModuleTest.java b/src/test/java/com/avaje/test/springsupport/EbeanSpringModuleTest.java index 2eecfd646..54f50f495 100644 --- a/src/test/java/com/avaje/test/springsupport/EbeanSpringModuleTest.java +++ b/src/test/java/com/avaje/test/springsupport/EbeanSpringModuleTest.java @@ -1,18 +1,18 @@ /** * 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 @@ -25,74 +25,79 @@ import static org.junit.Assert.assertTrue; import java.util.logging.Logger; import org.junit.Test; +import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * Unit test for Ebean Spring Module. * @since 18.05.2009 * @author E Mc Greal */ -@ContextConfiguration(locations={"/init-database.xml"}) -public class EbeanSpringModuleTest extends AbstractJUnit4SpringContextTests { +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = {"/init-database.xml"}) +public class EbeanSpringModuleTest { - /** The Constant logger. */ - private final static Logger logger = Logger.getLogger(EbeanSpringModuleTest.class.getName()); + /** The Constant logger. */ + private final static Logger logger = Logger.getLogger(EbeanSpringModuleTest.class.getName()); - /** The user service. */ - @Autowired - private UserService userService; + /** The user service. */ + @Autowired + private UserService userService; - /** - * Create the test case. - */ - public EbeanSpringModuleTest(){ - super(); - } + /** + * Create the test case. + */ + public EbeanSpringModuleTest() { + super(); + } - /** - * Test app. - */ - @Test - public void testSaveUser(){ - logger.info("Saving new User..."); - User user = new User(); - user.setName("ebean"); - userService.save(user); - logger.info("Saved new User"); - } + @Test + public void testBatchInsert() { - /** - * Test app. - */ - @Test - public void testFindUser(){ - logger.info("Finding User with OID = 1 ..."); - User user = userService.find(1); + userService.batchInsert(); + } - assertNotNull(user); - assertTrue("ebean".equals(user.getName())); - logger.info("Found User with OID = 1"); - } + /** + * Test app. + */ + @Test + public void testSaveUser() { + logger.info("Saving new User..."); + User user = new User(); + user.setName("ebean"); + userService.save(user); + logger.info("Saved new User"); + } - /** - * Gets the user service. - * - * @return the userService - */ - public UserService getUserService() { - return userService; - } + /** + * Test app. + */ + @Test + public void testFindUser() { + logger.info("Finding User with OID = 1 ..."); + User user = userService.find(1); + + assertNotNull(user); + assertTrue("ebean".equals(user.getName())); + logger.info("Found User with OID = 1"); + } + + /** + * Return the user service. + */ + public UserService getUserService() { + return userService; + } - /** - * Sets the user service. - * - * @param userService the userService to set - */ - public void setUserService(UserService userService) { - this.userService = userService; - } + /** + * Sets the user service. + */ + public void setUserService(UserService userService) { + this.userService = userService; + } } diff --git a/src/test/java/com/avaje/test/springsupport/Role.java b/src/test/java/com/avaje/test/springsupport/Role.java index e6fed39d2..02381291e 100644 --- a/src/test/java/com/avaje/test/springsupport/Role.java +++ b/src/test/java/com/avaje/test/springsupport/Role.java @@ -1,18 +1,18 @@ /** * 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 @@ -34,40 +34,28 @@ import javax.persistence.ManyToMany; */ @Entity public class Role { - @Id - long oid; - @ManyToMany - private Set users = new HashSet(); + @Id + Long id; - /** - * @return the oid - */ - public long getOid() { - return oid; - } + @ManyToMany + private Set users; - /** - * @param oid the oid to set - */ - public void setOid(long oid) { - this.oid = oid; - } + public Long getId() { + return id; + } - /** - * @return the users - */ - public Set getUsers() { - return users; - } + public void setId(Long id) { + this.id = id; + } - /** - * @param users the users to set - */ - public void setUsers(Set users) { - this.users = users; - } + public Set getUsers() { + return users; + } + public void setUsers(Set users) { + this.users = users; + } } diff --git a/src/test/java/com/avaje/test/springsupport/User.java b/src/test/java/com/avaje/test/springsupport/User.java index 430d777b7..eccf35e1a 100644 --- a/src/test/java/com/avaje/test/springsupport/User.java +++ b/src/test/java/com/avaje/test/springsupport/User.java @@ -17,16 +17,13 @@ * along with Ebean; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - package com.avaje.test.springsupport; -import java.util.HashSet; -import java.util.Set; - import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.ManyToMany; import javax.persistence.OneToOne; +import java.util.Set; /** * The Class User. @@ -41,63 +38,39 @@ public class User { private String name; @ManyToMany - private Set roles = new HashSet(); + private Set roles; @OneToOne(mappedBy="user") private Account account; - /** - * @return the oid - */ public long getOid() { return oid; } - /** - * @param oid the oid to set - */ public void setOid(long oid) { this.oid = oid; } - /** - * @return the roles - */ public Set getRoles() { return roles; } - /** - * @param roles the roles to set - */ public void setRoles(Set roles) { this.roles = roles; } - /** - * @return the name - */ public String getName() { return name; } - /** - * @param name the name to set - */ public void setName(String name) { this.name = name; } - /** - * @return the account - */ public Account getAccount() { return account; } - /** - * @param account the account to set - */ public void setAccount(Account account) { this.account = account; } diff --git a/src/test/java/com/avaje/test/springsupport/UserService.java b/src/test/java/com/avaje/test/springsupport/UserService.java index 072824263..8da63c0ae 100644 --- a/src/test/java/com/avaje/test/springsupport/UserService.java +++ b/src/test/java/com/avaje/test/springsupport/UserService.java @@ -26,6 +26,10 @@ package com.avaje.test.springsupport; * @author E Mc Greal */ public interface UserService { - public void save(User user); - public User find(long oid); + + void save(User user); + + User find(long id); + + void batchInsert(); } diff --git a/src/test/java/com/avaje/test/springsupport/UserServiceImpl.java b/src/test/java/com/avaje/test/springsupport/UserServiceImpl.java index eab077042..8bb82c305 100644 --- a/src/test/java/com/avaje/test/springsupport/UserServiceImpl.java +++ b/src/test/java/com/avaje/test/springsupport/UserServiceImpl.java @@ -20,12 +20,17 @@ package com.avaje.test.springsupport; +import com.avaje.ebean.Transaction; +import com.avaje.ebean.config.PersistBatch; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import com.avaje.ebean.EbeanServer; +import java.util.ArrayList; +import java.util.List; + /** * The Class UserServiceImpl. * @@ -47,15 +52,35 @@ public class UserServiceImpl implements UserService { } @Transactional(readOnly = true, propagation = Propagation.REQUIRED) - public User find(long oid) { - return ebeanServer.find(User.class, oid); + public User find(long id) { + return ebeanServer.find(User.class, id); } + @Transactional(readOnly = false, propagation = Propagation.REQUIRED) + public void batchInsert(){ + + List users = new ArrayList(); + for(int i=0 ;i<5;i++){ + User user = new User(); + user.setName("user"+i); + users.add(user); + } + + System.out.println("---------before batch-------"); + + Transaction tx = ebeanServer.beginTransaction(); + tx.setBatch(PersistBatch.NONE); + tx.setBatchOnCascade(PersistBatch.ALL); + tx.setBatchSize(20); + ebeanServer.saveAll(users);// + + System.out.println("---------after batch-------"); + } + + /** - * Gets the ebean server. - * - * @return the ebeanServer + * Return the ebean server. */ public EbeanServer getEbeanServer() { return ebeanServer; @@ -63,8 +88,6 @@ public class UserServiceImpl implements UserService { /** * Sets the ebean server. - * - * @param ebeanServer the ebeanServer to set */ public void setEbeanServer(EbeanServer ebeanServer) { this.ebeanServer = ebeanServer; diff --git a/src/test/resources/init-database.xml b/src/test/resources/init-database.xml index 220ba5051..42fea58d6 100644 --- a/src/test/resources/init-database.xml +++ b/src/test/resources/init-database.xml @@ -14,11 +14,15 @@ - - - - + + + + + + + + diff --git a/src/test/resources/jndi.properties b/src/test/resources/jndi.properties deleted file mode 100644 index a954f4c9c..000000000 --- a/src/test/resources/jndi.properties +++ /dev/null @@ -1 +0,0 @@ -java.naming.factory.initial = org.apache.xbean.spring.jndi.SpringInitialContextFactory diff --git a/src/test/resources/jndi.xml b/src/test/resources/jndi.xml deleted file mode 100644 index f7af2db77..000000000 --- a/src/test/resources/jndi.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From de5cf1df2c0bcfe2acad39599aeb58b1f0e3a65e Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 30 Jul 2015 04:54:25 +1200 Subject: [PATCH 019/116] No effective change - format --- .../springsupport/AgentLoaderSupport.java | 42 +-- .../factory/EbeanServerFactoryBean.java | 86 ++--- .../SpringAwareJdbcTransactionManager.java | 344 +++++++++--------- .../txn/SpringJdbcTransaction.java | 32 +- 4 files changed, 252 insertions(+), 252 deletions(-) diff --git a/src/main/java/com/avaje/ebean/springsupport/AgentLoaderSupport.java b/src/main/java/com/avaje/ebean/springsupport/AgentLoaderSupport.java index 940177208..b4ffee5b0 100644 --- a/src/main/java/com/avaje/ebean/springsupport/AgentLoaderSupport.java +++ b/src/main/java/com/avaje/ebean/springsupport/AgentLoaderSupport.java @@ -15,32 +15,32 @@ import org.springframework.beans.factory.InitializingBean; */ public class AgentLoaderSupport implements InitializingBean { - private Logger logger = LoggerFactory.getLogger(getClass()); + private Logger logger = LoggerFactory.getLogger(getClass()); - private int debug; - private String packages; + private int debug; + private String packages; - public int getDebug() { - return debug; - } + public int getDebug() { + return debug; + } - public void setDebug(int debug) { - this.debug = debug; - } + public void setDebug(int debug) { + this.debug = debug; + } - public String getPackages() { - return packages; - } + public String getPackages() { + return packages; + } - public void setPackages(String packages) { - this.packages = packages; - } + public void setPackages(String packages) { + this.packages = packages; + } - @Override - public void afterPropertiesSet() throws Exception { - String args = "debug=" + getDebug() + ";packages=" + getPackages(); - if (!AgentLoader.loadAgentFromClasspath("avaje-ebeanorm-agent", args)) { - logger.info("avaje-ebeanorm-agent not found in classpath - not dynamically loaded"); - } + @Override + public void afterPropertiesSet() throws Exception { + String args = "debug=" + getDebug() + ";packages=" + getPackages(); + if (!AgentLoader.loadAgentFromClasspath("avaje-ebeanorm-agent", args)) { + logger.info("avaje-ebeanorm-agent not found in classpath - not dynamically loaded"); } + } } diff --git a/src/main/java/com/avaje/ebean/springsupport/factory/EbeanServerFactoryBean.java b/src/main/java/com/avaje/ebean/springsupport/factory/EbeanServerFactoryBean.java index a1daaeb6e..3b9475393 100644 --- a/src/main/java/com/avaje/ebean/springsupport/factory/EbeanServerFactoryBean.java +++ b/src/main/java/com/avaje/ebean/springsupport/factory/EbeanServerFactoryBean.java @@ -1,18 +1,18 @@ /** * 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 @@ -34,52 +34,52 @@ import com.avaje.ebean.config.ServerConfig; */ public class EbeanServerFactoryBean implements InitializingBean, FactoryBean { - /** - * The Ebean server configuration. - */ - private ServerConfig serverConfig; + /** + * The Ebean server configuration. + */ + private ServerConfig serverConfig; - /** - * The EbeanServer instance. - */ - private EbeanServer ebeanServer; + /** + * The EbeanServer instance. + */ + private EbeanServer ebeanServer; - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() throws Exception { - if (serverConfig == null){ - throw new Exception("No ServerConig set. You must define a ServerConfig bean"); - } + if (serverConfig == null) { + throw new Exception("No ServerConig set. You must define a ServerConfig bean"); + } - // Create the new EbeanServer using the configuration - this.ebeanServer = EbeanServerFactory.create(serverConfig); - } + // Create the new EbeanServer using the configuration + this.ebeanServer = EbeanServerFactory.create(serverConfig); + } - public EbeanServer getObject() throws Exception { - return ebeanServer; - } + public EbeanServer getObject() throws Exception { + return ebeanServer; + } - public Class getObjectType() { - return EbeanServer.class; - } + public Class getObjectType() { + return EbeanServer.class; + } - /** - * Returns true for EbeanServer. - */ - public boolean isSingleton() { - return true; - } + /** + * Returns true for EbeanServer. + */ + public boolean isSingleton() { + return true; + } - /** - * Return the server configuration. - */ - public ServerConfig getServerConfig() { - return serverConfig; - } + /** + * Return the server configuration. + */ + public ServerConfig getServerConfig() { + return serverConfig; + } - /** - * Set the server configuration. - */ - public void setServerConfig(ServerConfig serverConfig) { - this.serverConfig = serverConfig; - } + /** + * Set the server configuration. + */ + public void setServerConfig(ServerConfig serverConfig) { + this.serverConfig = serverConfig; + } } diff --git a/src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java b/src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java index 0fb7ac0b0..76221a568 100644 --- a/src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java +++ b/src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java @@ -1,18 +1,18 @@ /** * 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 @@ -38,195 +38,195 @@ import com.avaje.ebeaninternal.server.transaction.TransactionManager; /** * A Spring aware TransactionScopeManager. - * + * *

* Will look for Spring transactions and use them if they exist. *

- * + * * @since 18.05.2009 * @author E Mc Greal */ public class SpringAwareJdbcTransactionManager implements ExternalTransactionManager { - private final static Logger logger = Logger.getLogger(SpringAwareJdbcTransactionManager.class.getName()); + private final static Logger logger = Logger.getLogger(SpringAwareJdbcTransactionManager.class.getName()); - /** - * The data source. - */ - private DataSource dataSource; + /** + * The data source. + */ + private DataSource dataSource; - /** - * The Ebean transaction manager. - */ - private TransactionManager transactionManager; + /** + * The Ebean transaction manager. + */ + private TransactionManager transactionManager; - /** - * The EbeanServer name. - */ - private String serverName; - - /** - * Instantiates a new spring aware transaction scope manager. - */ - public SpringAwareJdbcTransactionManager() { + /** + * The EbeanServer name. + */ + private String serverName; + + /** + * Instantiates a new spring aware transaction scope manager. + */ + public SpringAwareJdbcTransactionManager() { + } + + /** + * Initialise this with the Ebean internal transaction manager. + */ + public void setTransactionManager(Object txnMgr) { + + // RB: At this stage not exposing TransactionManager to + // the public API and hence the Object type and casting here + + this.transactionManager = (TransactionManager) txnMgr; + this.dataSource = transactionManager.getDataSource(); + this.serverName = transactionManager.getServerName(); + } + + /** + * 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). + *

+ */ + 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 = DefaultTransactionThreadLocal.get(serverName); + if (currentEbeanTransaction != null) { + // NOT expecting this so log WARNING + String msg = "SpringTransaction - no current spring txn BUT using current Ebean one " + currentEbeanTransaction.getId(); + logger.log(Level.WARNING, msg); + + } else if (logger.isLoggable(Level.FINEST)) { + logger.log(Level.FINEST, "Spring Txn - no current transaction "); + } + return currentEbeanTransaction; + } + + SpringTxnListener springTxnLister = getSpringTxnListener(); + + if (springTxnLister != null) { + // we have already seen this transaction + return springTxnLister.getTransaction(); + + } 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); + TransactionSynchronizationManager.registerSynchronization(springTxnLister); + + // also put in Ebean ThreadLocal + DefaultTransactionThreadLocal.set(serverName, newTrans); + return newTrans; + } + } + + /** + * Search for our specific transaction listener. + *

+ * If it exists then we have already seen and "wrapped" this transaction. + *

+ */ + private SpringTxnListener getSpringTxnListener() { + + if (TransactionSynchronizationManager.isSynchronizationActive()) { + 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); + } + } + } + } + + return null; + } + + /** + * 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. + *

+ */ + private SpringTxnListener createSpringTxnListener(SpringJdbcTransaction t) { + return new SpringTxnListener(transactionManager, t); + } + + /** + * 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. + *

+ */ + private static class SpringTxnListener extends TransactionSynchronizationAdapter { + + private final TransactionManager transactionManager; + + private final SpringJdbcTransaction transaction; + + private final String serverName; + + private SpringTxnListener(TransactionManager transactionManager, SpringJdbcTransaction t) { + this.transactionManager = transactionManager; + this.transaction = t; + this.serverName = transactionManager.getServerName(); } /** - * Initialise this with the Ebean internal transaction manager. + * Return the associated Ebean wrapped transaction. */ - public void setTransactionManager(Object txnMgr) { - - // RB: At this stage not exposing TransactionManager to - // the public API and hence the Object type and casting here - - this.transactionManager = (TransactionManager) txnMgr; - this.dataSource = transactionManager.getDataSource(); - this.serverName = transactionManager.getServerName(); + public SpringJdbcTransaction getTransaction() { + return transaction; } - /** - * 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). - *

- */ - 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 = DefaultTransactionThreadLocal.get(serverName); - if (currentEbeanTransaction != null){ - // NOT expecting this so log WARNING - String msg = "SpringTransaction - no current spring txn BUT using current Ebean one "+currentEbeanTransaction.getId(); - logger.log(Level.WARNING, msg); - - } else if (logger.isLoggable(Level.FINEST)) { - logger.log(Level.FINEST, "Spring Txn - no current transaction "); - } - return currentEbeanTransaction; - } - - SpringTxnListener springTxnLister = getSpringTxnListener(); - - if (springTxnLister != null){ - // we have already seen this transaction - return springTxnLister.getTransaction(); - - } 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); - TransactionSynchronizationManager.registerSynchronization(springTxnLister); - - // also put in Ebean ThreadLocal - DefaultTransactionThreadLocal.set(serverName, newTrans); - return newTrans; - } + @Override + public void beforeCommit(boolean readOnly) { + // Future note: for JPA2 locking we will + // have beforeCommit events to fire } - /** - * Search for our specific transaction listener. - *

- * If it exists then we have already seen and "wrapped" this transaction. - *

- */ - private SpringTxnListener getSpringTxnListener() { + @Override + public void afterCompletion(int status) { - if (TransactionSynchronizationManager.isSynchronizationActive()){ - 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); - } - } - } - } - - return null; - } - - /** - * 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. - *

- */ - private SpringTxnListener createSpringTxnListener(SpringJdbcTransaction t) { - return new SpringTxnListener(transactionManager, t); - } + switch (status) { + case STATUS_COMMITTED: + if (logger.isLoggable(Level.FINE)) { + logger.fine("Spring Txn [" + transaction.getId() + "] committed"); + } + transactionManager.notifyOfCommit(transaction); + break; - /** - * 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. - *

- */ - private static class SpringTxnListener extends TransactionSynchronizationAdapter { - - private final TransactionManager transactionManager; - - private final SpringJdbcTransaction transaction; - - private final String serverName; - - private SpringTxnListener(TransactionManager transactionManager, SpringJdbcTransaction t){ - this.transactionManager = transactionManager; - this.transaction = t; - this.serverName = transactionManager.getServerName(); - } - - /** - * Return the associated Ebean wrapped transaction. - */ - public SpringJdbcTransaction getTransaction() { - return transaction; - } - - @Override - public void beforeCommit(boolean readOnly) { - // Future note: for JPA2 locking we will - // have beforeCommit events to fire - } + case STATUS_ROLLED_BACK: + if (logger.isLoggable(Level.FINE)) { + logger.fine("Spring Txn [" + transaction.getId() + "] rollback"); + } + transactionManager.notifyOfRollback(transaction, null); + break; - @Override - public void afterCompletion(int status) { - - switch (status) { - case STATUS_COMMITTED: - if (logger.isLoggable(Level.FINE)){ - logger.fine("Spring Txn ["+transaction.getId()+"] committed"); - } - transactionManager.notifyOfCommit(transaction); - break; - - case STATUS_ROLLED_BACK: - if (logger.isLoggable(Level.FINE)){ - logger.fine("Spring Txn ["+transaction.getId()+"] rollback"); - } - transactionManager.notifyOfRollback(transaction, null); - break; - - default: - // this should never happen - String msg = "Invalid status "+status; - throw new PersistenceException(msg); - } - - // Remove this transaction object as it is completed - DefaultTransactionThreadLocal.replace(serverName, null); - } + default: + // this should never happen + String msg = "Invalid status " + status; + throw new PersistenceException(msg); + } + + // Remove this transaction object as it is completed + DefaultTransactionThreadLocal.replace(serverName, null); } + } } diff --git a/src/main/java/com/avaje/ebean/springsupport/txn/SpringJdbcTransaction.java b/src/main/java/com/avaje/ebean/springsupport/txn/SpringJdbcTransaction.java index 367e0f6bb..6b38fa7af 100644 --- a/src/main/java/com/avaje/ebean/springsupport/txn/SpringJdbcTransaction.java +++ b/src/main/java/com/avaje/ebean/springsupport/txn/SpringJdbcTransaction.java @@ -1,18 +1,18 @@ /** * 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 @@ -27,19 +27,19 @@ import com.avaje.ebeaninternal.server.transaction.TransactionManager; public class SpringJdbcTransaction extends ExternalJdbcTransaction { - private final ConnectionHolder holder; + private final ConnectionHolder holder; - public SpringJdbcTransaction(ConnectionHolder holder, TransactionManager manager) { - super("s"+holder.hashCode(), true, holder.getConnection(), manager); - this.holder = holder; - } + public SpringJdbcTransaction(ConnectionHolder holder, TransactionManager manager) { + super("s" + holder.hashCode(), true, holder.getConnection(), manager); + this.holder = holder; + } - @Override - public boolean isActive() { - return holder.isSynchronizedWithTransaction(); - } + @Override + public boolean isActive() { + return holder.isSynchronizedWithTransaction(); + } - public ConnectionHolder getConnectionHolder() { - return holder; - } + public ConnectionHolder getConnectionHolder() { + return holder; + } } From 166710742215441a65dbf880e85aaa2e5a2fee4c Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 30 Jul 2015 04:57:03 +1200 Subject: [PATCH 020/116] Update spring xsd to spring-beans-4.1.xsd --- src/main/resources/default-ebean-server.xml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/resources/default-ebean-server.xml b/src/main/resources/default-ebean-server.xml index 9dd031e65..789fe98d2 100644 --- a/src/main/resources/default-ebean-server.xml +++ b/src/main/resources/default-ebean-server.xml @@ -1,10 +1,7 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> From 6d1beb5c0310a78618a2d2455b9df5bc7d810f96 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 30 Jul 2015 05:03:05 +1200 Subject: [PATCH 021/116] Add javadoc-plugin to pom --- pom.xml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pom.xml b/pom.xml index 55b07566f..9f2f37f77 100644 --- a/pom.xml +++ b/pom.xml @@ -194,6 +194,35 @@ + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + 1.8 + org.avaje.doclet.PygmentsDoclet + + org.avaje + pygments-doclet + 1.0.0 + + + -Xdoclint:none + + true + + + + + attach-javadocs + + jar + + + + + From 07cc0fcbb645640586556e13a07e2f2248bd886c Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 30 Jul 2015 05:03:28 +1200 Subject: [PATCH 022/116] [maven-release-plugin] prepare release avaje-ebeanorm-spring-4.5.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9f2f37f77..cd17fe738 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 4.5.3-SNAPSHOT + 4.5.3 jar Support for Spring transactions and IOC setup of Ebean server config From 9620c57f199f42d657ba8eb03e654cb3b1ece927 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 30 Jul 2015 05:03:49 +1200 Subject: [PATCH 023/116] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cd17fe738..6c7f10006 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 4.5.3 + 4.5.4-SNAPSHOT jar Support for Spring transactions and IOC setup of Ebean server config From e2cb033119a26a25ff62a9549e590387f63746ab Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 4 Nov 2015 08:33:16 +1300 Subject: [PATCH 024/116] #5 - Error creating bean with name 'serverConfig' defined in class path resource [init-database.xml]: Cannot create inner bean 'com.avaje.ebean.config.AutofetchConfig#2e385cce' of type [com.avaje.ebean.config.AutofetchConfig] while setting bean property 'autofetchConfig' --- src/main/resources/default-ebean-server.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/resources/default-ebean-server.xml b/src/main/resources/default-ebean-server.xml index 789fe98d2..f2831531f 100644 --- a/src/main/resources/default-ebean-server.xml +++ b/src/main/resources/default-ebean-server.xml @@ -5,16 +5,9 @@ - - - - - - - From e50c372562fb87af93ad65dab61942ffcb43f7c2 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 4 Nov 2015 08:33:37 +1300 Subject: [PATCH 025/116] Bump pom to 6.1.1-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6c7f10006..15dd2f7e3 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 4.5.4-SNAPSHOT + 6.1.1-SNAPSHOT jar Support for Spring transactions and IOC setup of Ebean server config From d864e2c72310665ce6d287492ac0599a9b8ab1a0 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 4 Nov 2015 08:34:08 +1300 Subject: [PATCH 026/116] [maven-release-plugin] prepare release avaje-ebeanorm-spring-6.1.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 15dd2f7e3..2dc2cbb3e 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 6.1.1-SNAPSHOT + 6.1.1 jar Support for Spring transactions and IOC setup of Ebean server config From 2d375b35961480a6750b58847ff5cc70e6352d22 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 4 Nov 2015 08:34:33 +1300 Subject: [PATCH 027/116] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2dc2cbb3e..5634dd20b 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 6.1.1 + 6.1.2-SNAPSHOT jar Support for Spring transactions and IOC setup of Ebean server config From 40eada4e806190cf708f7bd2b11e7cc7c984c8cb Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 18 May 2016 08:33:04 +1200 Subject: [PATCH 028/116] #6 - Modify POM dependencies, change to provided scope for Ebean and Spring context --- pom.xml | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 5634dd20b..5c10c2a49 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,7 @@ 4.0.0 + org.avaje avaje-javaparent @@ -10,7 +11,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 6.1.2-SNAPSHOT + 7.1.1-SNAPSHOT jar Support for Spring transactions and IOC setup of Ebean server config @@ -38,28 +39,41 @@ - org.avaje.ebeanorm - avaje-ebeanorm - [6,7) + org.slf4j + jcl-over-slf4j + [1.7,) + + + org.avaje.ebeanorm + avaje-ebeanorm + [6,8) + provided + + + org.avaje.ebeanorm avaje-ebeanorm-agent [4.5,5) + provided + org.avaje avaje-agentloader 2.1.2 + provided - + org.springframework spring-context ${spring.framework.version} + provided @@ -113,12 +127,6 @@ - - org.slf4j - jcl-over-slf4j - 1.7.12 - - org.avaje.composite avaje-composite-testing-ebean @@ -134,7 +142,7 @@ org.avaje.ebeanorm avaje-ebeanorm-mavenenhancer - 4.5.3 + 4.10.1 main From 6090eaa1674ae5e7f746a64a40e432a7b97d208c Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 18 May 2016 08:33:34 +1200 Subject: [PATCH 029/116] [maven-release-plugin] prepare release avaje-ebeanorm-spring-7.1.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5c10c2a49..91cbd0357 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 7.1.1-SNAPSHOT + 7.1.1 jar Support for Spring transactions and IOC setup of Ebean server config From f07727651ea2b36de2cc1376ea8c46cf93ebf78b Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 18 May 2016 08:33:54 +1200 Subject: [PATCH 030/116] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 91cbd0357..89ceca8dc 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.avaje.ebeanorm avaje-ebeanorm-spring avaje-ebeanorm-spring - 7.1.1 + 7.1.2-SNAPSHOT jar Support for Spring transactions and IOC setup of Ebean server config From b12cfafc21f823ae3fb4fb971c2ee6e41e2cf5fa Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 3 Aug 2016 17:45:51 +1200 Subject: [PATCH 031/116] Change groupId to ... org.avaje.ebean, and artifactId to ... ebean-spring --- pom.xml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 89ceca8dc..b45725c41 100644 --- a/pom.xml +++ b/pom.xml @@ -8,9 +8,9 @@ 1.2 - org.avaje.ebeanorm - avaje-ebeanorm-spring - avaje-ebeanorm-spring + org.avaje.ebean + ebean-spring + ebean-spring 7.1.2-SNAPSHOT jar Support for Spring transactions and IOC setup of Ebean server config @@ -46,17 +46,17 @@ - org.avaje.ebeanorm - avaje-ebeanorm - [6,8) + org.avaje.ebean + ebean + 8.1.1 provided - org.avaje.ebeanorm - avaje-ebeanorm-agent - [4.5,5) + org.avaje.ebean + ebean-agent + 8.1.1 provided @@ -140,9 +140,9 @@ - org.avaje.ebeanorm - avaje-ebeanorm-mavenenhancer - 4.10.1 + org.avaje.ebean + ebean-maven-plugin + 8.1.1 main @@ -182,10 +182,10 @@ - org.avaje.ebeanorm + org.avaje.ebean - avaje-ebeanorm-mavenenhancer + ebean-maven-plugin [3,4) From 748090479239e651fb2b12773627082595196fe4 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 3 Aug 2016 17:46:18 +1200 Subject: [PATCH 032/116] [maven-release-plugin] prepare release ebean-spring-7.1.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b45725c41..27725a6b0 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.avaje.ebean ebean-spring ebean-spring - 7.1.2-SNAPSHOT + 7.1.2 jar Support for Spring transactions and IOC setup of Ebean server config From a1ce6f8a81dbe6e116c1641ae2100a5e8563e696 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 3 Aug 2016 17:46:37 +1200 Subject: [PATCH 033/116] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 27725a6b0..ca507fdbb 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.avaje.ebean ebean-spring ebean-spring - 7.1.2 + 7.1.3-SNAPSHOT jar Support for Spring transactions and IOC setup of Ebean server config From aa85c5fa3bbe2f4310a2f4be2b7133ccc86b4ae6 Mon Sep 17 00:00:00 2001 From: Karsten Sperling Date: Mon, 14 Nov 2016 13:30:03 +1300 Subject: [PATCH 034/116] Propagate 'flush' calls from Spring TX synchronization to the ebean transaction. --- .../txn/SpringAwareJdbcTransactionManager.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java b/src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java index 76221a568..c1fbea2e9 100644 --- a/src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java +++ b/src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java @@ -22,19 +22,16 @@ package com.avaje.ebean.springsupport.txn; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; - import javax.persistence.PersistenceException; import javax.sql.DataSource; - -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 com.avaje.ebean.config.ExternalTransactionManager; import com.avaje.ebeaninternal.api.SpiTransaction; import com.avaje.ebeaninternal.server.transaction.DefaultTransactionThreadLocal; import com.avaje.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; /** * A Spring aware TransactionScopeManager. @@ -74,6 +71,7 @@ public class SpringAwareJdbcTransactionManager implements ExternalTransactionMan /** * Initialise this with the Ebean internal transaction manager. */ + @Override public void setTransactionManager(Object txnMgr) { // RB: At this stage not exposing TransactionManager to @@ -90,6 +88,7 @@ public class SpringAwareJdbcTransactionManager implements ExternalTransactionMan * Returns null if there is no current spring transaction (lazy loading outside a spring txn etc). *

*/ + @Override public Object getCurrentTransaction() { // Get the current Spring ConnectionHolder associated to the current spring managed transaction @@ -195,6 +194,11 @@ public class SpringAwareJdbcTransactionManager implements ExternalTransactionMan return transaction; } + @Override + public void flush() { + transaction.flushBatch(); + } + @Override public void beforeCommit(boolean readOnly) { // Future note: for JPA2 locking we will From 92cdd25ca9d2da507f06bd768061f4fb5d7a70b9 Mon Sep 17 00:00:00 2001 From: Karsten Sperling Date: Thu, 17 Nov 2016 09:36:37 +1300 Subject: [PATCH 035/116] Use slf4j for logging and tidy up dependencies. --- pom.xml | 32 +++++------------- .../springsupport/AgentLoaderSupport.java | 2 +- .../SpringAwareJdbcTransactionManager.java | 33 +++++++------------ .../springsupport/EbeanSpringModuleTest.java | 7 ++-- .../com/avaje/test/springsupport/Role.java | 4 --- src/test/resources/init-database.xml | 5 +++ 6 files changed, 28 insertions(+), 55 deletions(-) diff --git a/pom.xml b/pom.xml index ca507fdbb..0b7ea871c 100644 --- a/pom.xml +++ b/pom.xml @@ -37,10 +37,9 @@ - org.slf4j - jcl-over-slf4j + slf4j-api [1.7,) @@ -74,25 +73,6 @@ spring-context ${spring.framework.version} provided -
- - - org.springframework - spring-core - ${spring.framework.version} - provided - - - commons-logging - commons-logging - - - - - org.springframework - spring-aspects - ${spring.framework.version} - provided commons-logging @@ -135,6 +115,12 @@ test + + org.slf4j + jcl-over-slf4j + [1.7,) + test + @@ -170,7 +156,7 @@
- org.eclipse.m2e @@ -230,7 +216,7 @@ - + diff --git a/src/main/java/com/avaje/ebean/springsupport/AgentLoaderSupport.java b/src/main/java/com/avaje/ebean/springsupport/AgentLoaderSupport.java index b4ffee5b0..11bd6a0c2 100644 --- a/src/main/java/com/avaje/ebean/springsupport/AgentLoaderSupport.java +++ b/src/main/java/com/avaje/ebean/springsupport/AgentLoaderSupport.java @@ -7,7 +7,7 @@ import org.springframework.beans.factory.InitializingBean; /** * To Setup Enhancement in Spring - * + * * * * diff --git a/src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java b/src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java index c1fbea2e9..e6402b3b5 100644 --- a/src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java +++ b/src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java @@ -20,22 +20,21 @@ package com.avaje.ebean.springsupport.txn; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.persistence.PersistenceException; import javax.sql.DataSource; import com.avaje.ebean.config.ExternalTransactionManager; import com.avaje.ebeaninternal.api.SpiTransaction; import com.avaje.ebeaninternal.server.transaction.DefaultTransactionThreadLocal; import com.avaje.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; import org.springframework.transaction.support.TransactionSynchronizationManager; /** - * A Spring aware TransactionScopeManager. - * + * A Spring-aware {@link ExternalTransactionManager}. *

* Will look for Spring transactions and use them if they exist. *

@@ -45,7 +44,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager */ public class SpringAwareJdbcTransactionManager implements ExternalTransactionManager { - private final static Logger logger = Logger.getLogger(SpringAwareJdbcTransactionManager.class.getName()); + private static final Logger log = LoggerFactory.getLogger(SpringAwareJdbcTransactionManager.class); /** * The data source. @@ -97,23 +96,18 @@ public class SpringAwareJdbcTransactionManager implements ExternalTransactionMan if (holder == null || !holder.isSynchronizedWithTransaction()) { // no current Spring transaction SpiTransaction currentEbeanTransaction = DefaultTransactionThreadLocal.get(serverName); - if (currentEbeanTransaction != null) { - // NOT expecting this so log WARNING - String msg = "SpringTransaction - no current spring txn BUT using current Ebean one " + currentEbeanTransaction.getId(); - logger.log(Level.WARNING, msg); - - } else if (logger.isLoggable(Level.FINEST)) { - logger.log(Level.FINEST, "Spring Txn - no current transaction "); + if (currentEbeanTransaction != null) { // this is unexpected + log.warn("No current Spring transaction BUT using current Ebean one {}", currentEbeanTransaction.getId()); + } else { + log.trace("No current Spring transaction"); } return currentEbeanTransaction; } SpringTxnListener springTxnLister = getSpringTxnListener(); - if (springTxnLister != null) { // we have already seen this transaction return springTxnLister.getTransaction(); - } else { // This is a new spring transaction that we have not seen before. // "wrap" it in a SpringJdbcTransaction for use with Ebean @@ -210,23 +204,18 @@ public class SpringAwareJdbcTransactionManager implements ExternalTransactionMan switch (status) { case STATUS_COMMITTED: - if (logger.isLoggable(Level.FINE)) { - logger.fine("Spring Txn [" + transaction.getId() + "] committed"); - } + log.debug("Spring Txn [{}] committed", transaction.getId()); transactionManager.notifyOfCommit(transaction); break; case STATUS_ROLLED_BACK: - if (logger.isLoggable(Level.FINE)) { - logger.fine("Spring Txn [" + transaction.getId() + "] rollback"); - } + log.debug("Spring Txn [{}] rollback", transaction.getId()); transactionManager.notifyOfRollback(transaction, null); break; default: // this should never happen - String msg = "Invalid status " + status; - throw new PersistenceException(msg); + throw new PersistenceException("Invalid status " + status); } // Remove this transaction object as it is completed diff --git a/src/test/java/com/avaje/test/springsupport/EbeanSpringModuleTest.java b/src/test/java/com/avaje/test/springsupport/EbeanSpringModuleTest.java index 54f50f495..6d31d3e2d 100644 --- a/src/test/java/com/avaje/test/springsupport/EbeanSpringModuleTest.java +++ b/src/test/java/com/avaje/test/springsupport/EbeanSpringModuleTest.java @@ -19,17 +19,14 @@ */ package com.avaje.test.springsupport; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.util.logging.Logger; - import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; /** * Unit test for Ebean Spring Module. diff --git a/src/test/java/com/avaje/test/springsupport/Role.java b/src/test/java/com/avaje/test/springsupport/Role.java index 02381291e..1ff6aa60e 100644 --- a/src/test/java/com/avaje/test/springsupport/Role.java +++ b/src/test/java/com/avaje/test/springsupport/Role.java @@ -20,9 +20,7 @@ package com.avaje.test.springsupport; -import java.util.HashSet; import java.util.Set; - import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.ManyToMany; @@ -56,6 +54,4 @@ public class Role { public void setUsers(Set users) { this.users = users; } - - } diff --git a/src/test/resources/init-database.xml b/src/test/resources/init-database.xml index 42fea58d6..d0739c9c0 100644 --- a/src/test/resources/init-database.xml +++ b/src/test/resources/init-database.xml @@ -8,6 +8,11 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> + + + + + From 463b03ef7c427fb600fc826b95629f63652cb62d Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 12:18:01 +1300 Subject: [PATCH 036/116] bump pom to 7.2.1-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0b7ea871c..e4635698c 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.avaje.ebean ebean-spring ebean-spring - 7.1.3-SNAPSHOT + 7.2.1-SNAPSHOT jar Support for Spring transactions and IOC setup of Ebean server config From 2a2a0ad1f41901bfc7f54f8a8c98a272064c2e83 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 12:19:12 +1300 Subject: [PATCH 037/116] [maven-release-plugin] prepare release ebean-spring-7.2.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e4635698c..0b4e6a608 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.avaje.ebean ebean-spring ebean-spring - 7.2.1-SNAPSHOT + 7.2.1 jar Support for Spring transactions and IOC setup of Ebean server config From d49018363cfb53cc4b61cc2a0a65849713055f9c Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 12:19:27 +1300 Subject: [PATCH 038/116] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0b4e6a608..4f2371981 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.avaje.ebean ebean-spring ebean-spring - 7.2.1 + 7.2.2-SNAPSHOT jar Support for Spring transactions and IOC setup of Ebean server config From 326fc221bf5606d94e6a8ffa33778ae8145b99f2 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 12:29:02 +1300 Subject: [PATCH 039/116] pom - modify scm to use ssh --- pom.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 4f2371981..280c82902 100644 --- a/pom.xml +++ b/pom.xml @@ -31,9 +31,7 @@ - scm:git:https://github.com/ebean-orm/avaje-ebeanorm-spring.git - scm:git:https://github.com/ebean-orm/avaje-ebeanorm-spring.git - https://github.com/ebean-orm/avaje-ebeanorm-spring.git + scm:git:git@github.com:ebean-orm/avaje-ebeanorm-spring.git From 2f793c29dc247b81ba6f64a7e4dbc458ee994829 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 13 Dec 2016 21:50:11 +1300 Subject: [PATCH 040/116] #11 - Repackage to io.ebean.springtxn ... remove factory bean support (move it to src/test as example) --- pom.xml | 96 ++++++------------- src/main/java/META-INF/MANIFEST.MF | 3 - .../springsupport/AgentLoaderSupport.java | 46 --------- .../SpringAwareJdbcTransactionManager.java | 17 ++-- .../springtxn}/SpringJdbcTransaction.java | 6 +- src/main/resources/META-INF/MANIFEST.MF | 18 ---- .../example}/Account.java | 2 +- .../org/example}/EbeanServerFactoryBean.java | 8 +- .../example}/EbeanSpringModuleTest.java | 2 +- .../springsupport => org/example}/Role.java | 2 +- .../springsupport => org/example}/User.java | 2 +- .../example}/UserService.java | 2 +- .../example}/UserServiceImpl.java | 8 +- .../resources/default-ebean-server.xml | 6 +- src/test/resources/init-database.xml | 18 ++-- 15 files changed, 64 insertions(+), 172 deletions(-) delete mode 100644 src/main/java/META-INF/MANIFEST.MF delete mode 100644 src/main/java/com/avaje/ebean/springsupport/AgentLoaderSupport.java rename src/main/java/{com/avaje/ebean/springsupport/txn => io/ebean/springtxn}/SpringAwareJdbcTransactionManager.java (96%) rename src/main/java/{com/avaje/ebean/springsupport/txn => io/ebean/springtxn}/SpringJdbcTransaction.java (87%) delete mode 100644 src/main/resources/META-INF/MANIFEST.MF rename src/test/java/{com/avaje/test/springsupport => org/example}/Account.java (97%) rename src/{main/java/com/avaje/ebean/springsupport/factory => test/java/org/example}/EbeanServerFactoryBean.java (92%) rename src/test/java/{com/avaje/test/springsupport => org/example}/EbeanSpringModuleTest.java (98%) rename src/test/java/{com/avaje/test/springsupport => org/example}/Role.java (97%) rename src/test/java/{com/avaje/test/springsupport => org/example}/User.java (97%) rename src/test/java/{com/avaje/test/springsupport => org/example}/UserService.java (96%) rename src/test/java/{com/avaje/test/springsupport => org/example}/UserServiceImpl.java (94%) rename src/{main => test}/resources/default-ebean-server.xml (64%) diff --git a/pom.xml b/pom.xml index 280c82902..611442188 100644 --- a/pom.xml +++ b/pom.xml @@ -4,31 +4,22 @@ org.avaje - avaje-javaparent - 1.2 + java8-parent + 1.3 - org.avaje.ebean - ebean-spring - ebean-spring - 7.2.2-SNAPSHOT + io.ebean + ebean-springtxn + ebean-springtxn + 10.1.1-SNAPSHOT jar - Support for Spring transactions and IOC setup of Ebean server config + Support for Spring transaction use with Ebean - UTF-8 - 4.1.7.RELEASE + 4.3.4.RELEASE - http://www.avaje.org - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - + http://ebean-orm.github.io/ scm:git:git@github.com:ebean-orm/avaje-ebeanorm-spring.git @@ -39,31 +30,32 @@ org.slf4j slf4j-api [1.7,) + provided - org.avaje.ebean + io.ebean ebean - 8.1.1 + 10.1.1 provided - org.avaje.ebean + io.ebean ebean-agent - 8.1.1 + 10.1.1 provided - - org.avaje - avaje-agentloader - 2.1.2 - provided - + + + + + + @@ -124,17 +116,17 @@ - org.avaje.ebean + io.ebean ebean-maven-plugin - 8.1.1 + 10.1.1 main process-test-classes target/test-classes - com.avaje.** - debug=9 + org.example.** + debug=1 enhance @@ -165,15 +157,9 @@ - - org.avaje.ebean - - - ebean-maven-plugin - - - [3,4) - + io.ebean + ebean-maven-plugin + [10,11) enhance @@ -187,34 +173,6 @@ - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9.1 - - 1.8 - org.avaje.doclet.PygmentsDoclet - - org.avaje - pygments-doclet - 1.0.0 - - - -Xdoclint:none - - true - - - - - attach-javadocs - - jar - - - - -
diff --git a/src/main/java/META-INF/MANIFEST.MF b/src/main/java/META-INF/MANIFEST.MF deleted file mode 100644 index 254272e1c..000000000 --- a/src/main/java/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: - diff --git a/src/main/java/com/avaje/ebean/springsupport/AgentLoaderSupport.java b/src/main/java/com/avaje/ebean/springsupport/AgentLoaderSupport.java deleted file mode 100644 index 11bd6a0c2..000000000 --- a/src/main/java/com/avaje/ebean/springsupport/AgentLoaderSupport.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.avaje.ebean.springsupport; - -import org.avaje.agentloader.AgentLoader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; - -/** - * To Setup Enhancement in Spring - * - * - * - * - * Created by guor on 2015/5/11. - */ -public class AgentLoaderSupport implements InitializingBean { - - private Logger logger = LoggerFactory.getLogger(getClass()); - - private int debug; - private String packages; - - public int getDebug() { - return debug; - } - - public void setDebug(int debug) { - this.debug = debug; - } - - public String getPackages() { - return packages; - } - - public void setPackages(String packages) { - this.packages = packages; - } - - @Override - public void afterPropertiesSet() throws Exception { - String args = "debug=" + getDebug() + ";packages=" + getPackages(); - if (!AgentLoader.loadAgentFromClasspath("avaje-ebeanorm-agent", args)) { - logger.info("avaje-ebeanorm-agent not found in classpath - not dynamically loaded"); - } - } -} diff --git a/src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java b/src/main/java/io/ebean/springtxn/SpringAwareJdbcTransactionManager.java similarity index 96% rename from src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java rename to src/main/java/io/ebean/springtxn/SpringAwareJdbcTransactionManager.java index e6402b3b5..38e64c476 100644 --- a/src/main/java/com/avaje/ebean/springsupport/txn/SpringAwareJdbcTransactionManager.java +++ b/src/main/java/io/ebean/springtxn/SpringAwareJdbcTransactionManager.java @@ -17,15 +17,12 @@ * along with Ebean; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -package com.avaje.ebean.springsupport.txn; +package io.ebean.springtxn; -import java.util.List; -import javax.persistence.PersistenceException; -import javax.sql.DataSource; -import com.avaje.ebean.config.ExternalTransactionManager; -import com.avaje.ebeaninternal.api.SpiTransaction; -import com.avaje.ebeaninternal.server.transaction.DefaultTransactionThreadLocal; -import com.avaje.ebeaninternal.server.transaction.TransactionManager; +import io.ebean.config.ExternalTransactionManager; +import io.ebeaninternal.api.SpiTransaction; +import io.ebeaninternal.server.transaction.DefaultTransactionThreadLocal; +import io.ebeaninternal.server.transaction.TransactionManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.jdbc.datasource.ConnectionHolder; @@ -33,6 +30,10 @@ import org.springframework.transaction.support.TransactionSynchronization; import org.springframework.transaction.support.TransactionSynchronizationAdapter; import org.springframework.transaction.support.TransactionSynchronizationManager; +import javax.persistence.PersistenceException; +import javax.sql.DataSource; +import java.util.List; + /** * A Spring-aware {@link ExternalTransactionManager}. *

diff --git a/src/main/java/com/avaje/ebean/springsupport/txn/SpringJdbcTransaction.java b/src/main/java/io/ebean/springtxn/SpringJdbcTransaction.java similarity index 87% rename from src/main/java/com/avaje/ebean/springsupport/txn/SpringJdbcTransaction.java rename to src/main/java/io/ebean/springtxn/SpringJdbcTransaction.java index 6b38fa7af..ac420f9e0 100644 --- a/src/main/java/com/avaje/ebean/springsupport/txn/SpringJdbcTransaction.java +++ b/src/main/java/io/ebean/springtxn/SpringJdbcTransaction.java @@ -18,12 +18,12 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -package com.avaje.ebean.springsupport.txn; +package io.ebean.springtxn; import org.springframework.jdbc.datasource.ConnectionHolder; -import com.avaje.ebeaninternal.server.transaction.ExternalJdbcTransaction; -import com.avaje.ebeaninternal.server.transaction.TransactionManager; +import io.ebeaninternal.server.transaction.ExternalJdbcTransaction; +import io.ebeaninternal.server.transaction.TransactionManager; public class SpringJdbcTransaction extends ExternalJdbcTransaction { diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index e025373c1..000000000 --- a/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,18 +0,0 @@ -Manifest-Version: 1.0 -Premain-Class: com.avaje.ebean.enhance.agent.Transformer -Bundle-ManifestVersion: 2 -Bundle-Name: Ebean-ORM-SPRING -Bundle-SymbolicName: com.avaje.ebean.springsupport -Bundle-Version: 4.1.9 -Bundle-ClassPath: . -Bundle-Vendor: avaje -Export-Package: com.avaje.ebean.springsupport.factory, - com.avaje.ebean.springsupport.txn -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Require-Bundle: com.avaje.ebean;bundle-version="4.1.9", - org.springframework.beans;bundle-version="3.1.0", - org.springframework.context;bundle-version="3.1.0", - org.slf4j.api;bundle-version="1.7.2" -Import-Package: javax.persistence;version="2.0.0" - - diff --git a/src/test/java/com/avaje/test/springsupport/Account.java b/src/test/java/org/example/Account.java similarity index 97% rename from src/test/java/com/avaje/test/springsupport/Account.java rename to src/test/java/org/example/Account.java index 12043ed5d..944602524 100644 --- a/src/test/java/com/avaje/test/springsupport/Account.java +++ b/src/test/java/org/example/Account.java @@ -17,7 +17,7 @@ * along with Ebean; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -package com.avaje.test.springsupport; +package org.example; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/src/main/java/com/avaje/ebean/springsupport/factory/EbeanServerFactoryBean.java b/src/test/java/org/example/EbeanServerFactoryBean.java similarity index 92% rename from src/main/java/com/avaje/ebean/springsupport/factory/EbeanServerFactoryBean.java rename to src/test/java/org/example/EbeanServerFactoryBean.java index 3b9475393..295e5e90b 100644 --- a/src/main/java/com/avaje/ebean/springsupport/factory/EbeanServerFactoryBean.java +++ b/src/test/java/org/example/EbeanServerFactoryBean.java @@ -17,14 +17,14 @@ * along with Ebean; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -package com.avaje.ebean.springsupport.factory; +package org.example; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; -import com.avaje.ebean.EbeanServer; -import com.avaje.ebean.EbeanServerFactory; -import com.avaje.ebean.config.ServerConfig; +import io.ebean.EbeanServer; +import io.ebean.EbeanServerFactory; +import io.ebean.config.ServerConfig; /** * A Spring FactoryBean for constructing EbeanServer instances. diff --git a/src/test/java/com/avaje/test/springsupport/EbeanSpringModuleTest.java b/src/test/java/org/example/EbeanSpringModuleTest.java similarity index 98% rename from src/test/java/com/avaje/test/springsupport/EbeanSpringModuleTest.java rename to src/test/java/org/example/EbeanSpringModuleTest.java index 6d31d3e2d..a17452005 100644 --- a/src/test/java/com/avaje/test/springsupport/EbeanSpringModuleTest.java +++ b/src/test/java/org/example/EbeanSpringModuleTest.java @@ -17,7 +17,7 @@ * along with Ebean; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -package com.avaje.test.springsupport; +package org.example; import java.util.logging.Logger; import org.junit.Test; diff --git a/src/test/java/com/avaje/test/springsupport/Role.java b/src/test/java/org/example/Role.java similarity index 97% rename from src/test/java/com/avaje/test/springsupport/Role.java rename to src/test/java/org/example/Role.java index 1ff6aa60e..41239de62 100644 --- a/src/test/java/com/avaje/test/springsupport/Role.java +++ b/src/test/java/org/example/Role.java @@ -18,7 +18,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -package com.avaje.test.springsupport; +package org.example; import java.util.Set; import javax.persistence.Entity; diff --git a/src/test/java/com/avaje/test/springsupport/User.java b/src/test/java/org/example/User.java similarity index 97% rename from src/test/java/com/avaje/test/springsupport/User.java rename to src/test/java/org/example/User.java index eccf35e1a..ec7bc2a1b 100644 --- a/src/test/java/com/avaje/test/springsupport/User.java +++ b/src/test/java/org/example/User.java @@ -17,7 +17,7 @@ * along with Ebean; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -package com.avaje.test.springsupport; +package org.example; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/src/test/java/com/avaje/test/springsupport/UserService.java b/src/test/java/org/example/UserService.java similarity index 96% rename from src/test/java/com/avaje/test/springsupport/UserService.java rename to src/test/java/org/example/UserService.java index 8da63c0ae..c4e7301c9 100644 --- a/src/test/java/com/avaje/test/springsupport/UserService.java +++ b/src/test/java/org/example/UserService.java @@ -18,7 +18,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -package com.avaje.test.springsupport; +package org.example; /** * The Interface UserService. diff --git a/src/test/java/com/avaje/test/springsupport/UserServiceImpl.java b/src/test/java/org/example/UserServiceImpl.java similarity index 94% rename from src/test/java/com/avaje/test/springsupport/UserServiceImpl.java rename to src/test/java/org/example/UserServiceImpl.java index 8bb82c305..b828010a6 100644 --- a/src/test/java/com/avaje/test/springsupport/UserServiceImpl.java +++ b/src/test/java/org/example/UserServiceImpl.java @@ -18,15 +18,15 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -package com.avaje.test.springsupport; +package org.example; -import com.avaje.ebean.Transaction; -import com.avaje.ebean.config.PersistBatch; +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; -import com.avaje.ebean.EbeanServer; +import io.ebean.EbeanServer; import java.util.ArrayList; import java.util.List; diff --git a/src/main/resources/default-ebean-server.xml b/src/test/resources/default-ebean-server.xml similarity index 64% rename from src/main/resources/default-ebean-server.xml rename to src/test/resources/default-ebean-server.xml index f2831531f..a325cec3e 100644 --- a/src/main/resources/default-ebean-server.xml +++ b/src/test/resources/default-ebean-server.xml @@ -4,12 +4,12 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> - + - + - + diff --git a/src/test/resources/init-database.xml b/src/test/resources/init-database.xml index d0739c9c0..2273a21f3 100644 --- a/src/test/resources/init-database.xml +++ b/src/test/resources/init-database.xml @@ -8,10 +8,10 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> - - - - + + + + @@ -38,9 +38,9 @@ - com.avaje.test.springsupport.User - com.avaje.test.springsupport.Role - com.avaje.test.springsupport.Account + org.example.User + org.example.Role + org.example.Account @@ -50,11 +50,11 @@ - + - + From 6eb1947a6e04a8436a9e6a06f641b55ef51abcac Mon Sep 17 00:00:00 2001 From: Karsten Sperling Date: Fri, 16 Dec 2016 22:41:31 +1300 Subject: [PATCH 041/116] Add EbeanAgentAutoConfiguration for Spring Boot --- pom.xml | 57 ++++++++------- .../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 +++ src/test/resources/init-database.xml | 7 +- 7 files changed, 163 insertions(+), 29 deletions(-) create mode 100644 src/main/java/io/ebean/spring/boot/EbeanAgentAutoConfiguration.java create mode 100644 src/main/resources/META-INF/spring.factories create mode 100644 src/test/java/io/ebean/spring/boot/EbeanAgentAutoConfigurationTest.java create mode 100644 src/test/java/org/unenhanced/Boondoggle.java create mode 100644 src/test/java/org/unenhanced/Wotsit.java diff --git a/pom.xml b/pom.xml index 611442188..ee4b98a2a 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,7 @@ 4.3.4.RELEASE + 1.4.2.RELEASE http://ebean-orm.github.io/ @@ -41,35 +42,23 @@ provided - + io.ebean ebean-agent - 10.1.1 - provided + [10,) + runtime + true - - - - - - - - - - - org.springframework - spring-context - ${spring.framework.version} - provided - - - commons-logging - commons-logging - - + + org.avaje + avaje-agentloader + 2.1.2 + true + + org.springframework spring-jdbc @@ -83,6 +72,13 @@ + + org.springframework.boot + spring-boot-autoconfigure + ${spring.boot.version} + provided + + org.springframework @@ -97,6 +93,13 @@ + + org.springframework.boot + spring-boot-test + ${spring.boot.version} + test + + org.avaje.composite avaje-composite-testing-ebean @@ -143,6 +146,14 @@ + + maven-surefire-plugin + 2.18.1 + + + false + + diff --git a/src/main/java/io/ebean/spring/boot/EbeanAgentAutoConfiguration.java b/src/main/java/io/ebean/spring/boot/EbeanAgentAutoConfiguration.java new file mode 100644 index 000000000..d9970a77a --- /dev/null +++ b/src/main/java/io/ebean/spring/boot/EbeanAgentAutoConfiguration.java @@ -0,0 +1,69 @@ +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 new file mode 100644 index 000000000..d4fedf3b0 --- /dev/null +++ b/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +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 new file mode 100644 index 000000000..bbd7bc81e --- /dev/null +++ b/src/test/java/io/ebean/spring/boot/EbeanAgentAutoConfigurationTest.java @@ -0,0 +1,35 @@ +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 new file mode 100644 index 000000000..0d23f258d --- /dev/null +++ b/src/test/java/org/unenhanced/Boondoggle.java @@ -0,0 +1,11 @@ +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 new file mode 100644 index 000000000..e2e723caf --- /dev/null +++ b/src/test/java/org/unenhanced/Wotsit.java @@ -0,0 +1,11 @@ +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; +} diff --git a/src/test/resources/init-database.xml b/src/test/resources/init-database.xml index 2273a21f3..0ccf4cd6b 100644 --- a/src/test/resources/init-database.xml +++ b/src/test/resources/init-database.xml @@ -8,11 +8,6 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> - - - - - @@ -24,7 +19,7 @@ + value="jdbc:h2:mem:ebean-testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false" /> From e0c4f73600332678732bf5707a438cd63e09d03c Mon Sep 17 00:00:00 2001 From: Karsten Sperling Date: Fri, 16 Dec 2016 22:45:30 +1300 Subject: [PATCH 042/116] POM tidying --- pom.xml | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index ee4b98a2a..6c3222ef8 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ http://ebean-orm.github.io/ - scm:git:git@github.com:ebean-orm/avaje-ebeanorm-spring.git + scm:git:git@github.com:ebean-orm/ebean-spring.git @@ -31,15 +31,12 @@ org.slf4j slf4j-api [1.7,) - provided - io.ebean ebean - 10.1.1 - provided + [10,) @@ -137,15 +134,6 @@ - - org.apache.maven.plugins - maven-jar-plugin - - - src/main/resources/META-INF/MANIFEST.MF - - - maven-surefire-plugin 2.18.1 @@ -155,6 +143,7 @@ + - + 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 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 @@ +[![Maven Central : ebean](https://maven-badges.herokuapp.com/maven-central/io.ebean/ebean-spring-txn/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.ebean/ebean-spring-txn) +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](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