mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2c82263ee | ||
|
|
30f3d542b3 | ||
|
|
56cb2c69aa | ||
|
|
bd1dd43cbf | ||
|
|
5caae29df9 | ||
|
|
9713b607b5 | ||
|
|
0e46558cae | ||
|
|
2386f1034b | ||
|
|
ddf9f5c508 | ||
|
|
559867294f | ||
|
|
bf0c8d8dab | ||
|
|
7077e92cb0 |
@@ -5,12 +5,12 @@
|
||||
<parent>
|
||||
<groupId>org.avaje</groupId>
|
||||
<artifactId>java8-oss</artifactId>
|
||||
<version>2.3</version>
|
||||
<version>3.2</version>
|
||||
</parent>
|
||||
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-spring-txn</artifactId>
|
||||
<version>12.6.3</version>
|
||||
<version>12.12.0</version>
|
||||
|
||||
<name>ebean-spring-txn</name>
|
||||
<packaging>jar</packaging>
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
<scm>
|
||||
<developerConnection>scm:git:git@github.com:ebean-orm/ebean-spring-txn.git</developerConnection>
|
||||
<tag>ebean-spring-txn-12.6.3</tag>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
@@ -39,10 +39,17 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean</artifactId>
|
||||
<version>12.6.3</version>
|
||||
<version>12.12.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-ddl-generator</artifactId>
|
||||
<version>12.12.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
@@ -102,7 +109,7 @@
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>1.4.196</version>
|
||||
<version>1.4.199</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -127,11 +134,11 @@
|
||||
<plugin>
|
||||
<groupId>io.repaint.maven</groupId>
|
||||
<artifactId>tiles-maven-plugin</artifactId>
|
||||
<version>2.18</version>
|
||||
<version>2.24</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<tiles>
|
||||
<tile>io.ebean.tile:enhancement:12.6.1</tile>
|
||||
<tile>io.ebean.tile:enhancement:12.12.0</tile>
|
||||
</tiles>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -62,10 +62,14 @@ public class EbeanSpringModuleTest {
|
||||
|
||||
@Test
|
||||
public void testBatchInsert() {
|
||||
|
||||
userService.batchInsert();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequiresNew() {
|
||||
userService.requiresNew();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test app.
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -14,4 +14,6 @@ public interface UserService {
|
||||
void nonTransactional();
|
||||
|
||||
void batchInsert();
|
||||
|
||||
void requiresNew();
|
||||
}
|
||||
|
||||
@@ -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,8 +62,18 @@ public class UserServiceImpl implements UserService {
|
||||
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.
|
||||
@@ -75,4 +90,8 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user