#16 - Bump to support Ebean 11.5.1+

This commit is contained in:
Rob Bygrave
2018-01-30 23:52:40 +13:00
parent 6bcc8eb0f2
commit dca824b431
4 changed files with 80 additions and 33 deletions
+7 -14
View File
@@ -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<User> users = new ArrayList<User>();
for(int i=0 ;i<5;i++){
List<User> 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-------");
}