java 报错:javax.transaction.rollbackexception transaction set to rollback only

wenwen1 发布于 2013/03/26 13:43
阅读 2K+
收藏 1

后台代码如下:

public List<Project> findAllActivitiesByDay()
{
 Set<User> useres=userDAO.findUserByEnabled(true);
List<Project> list3 = new ArrayList<Project>();
Calendar time=Calendar.getInstance();
int month=time.get(Calendar.MONTH);
int year=time.get(Calendar.YEAR);
int day=time.get(Calendar.DAY_OF_MONTH);
for(int i=day;i>0;i--){
Project project2=new Project();
project2.setCreateDate(Calendar.getInstance());
project2.getCreateDate().set(year, month, i, 0, 0, 0);
Calendar atime=project2.getCreateDate();
Set<Activity> acts=project2.getActivities();
Set<Task> tasks=project2.getTasks();
Set<ProjectFinance>  finances=project2.getProjectFinances();
List<User> users=new ArrayList<User>();
 users.addAll(useres);
for(User user:users){
int id=user.getId();
StringBuffer sb = new StringBuffer("select a from Activity a where 1=1 and a.activityTime='"+atime+"' and a.userByCreater.id='"+id+"'");
   List<Activity> activitys=activityDAO.executeQuery(sb.toString());
   if(activitys.size()>0){
    Activity activity=activitys.get(0);
    Calendar actTime=activity.getActivityTime();
    Calendar createTime=activity.getCreatedDate();
    int actDay=actTime.get(Calendar.DAY_OF_MONTH);
    int createDay=createTime.get(Calendar.DAY_OF_MONTH);
    int createHour=createTime.get(Calendar.HOUR);
    if(actDay==createDay){
    acts.add(activity);
    }else{
    if(actDay+2>createDay&&createHour<11)
    {
    acts.add(activity);
    }
    else{
    Task task=new Task();
    task.setUserByResponser(user);
    tasks.add(task);
    }
    }
   }else{
    ProjectFinance finance=new ProjectFinance();
  finance.setUserByCreater(user);
  finances.add(finance);
   }
}
list3.add(project2);
}
return list3;
}

报如下错误:
javax.transaction.RollbackException: Transaction set to rollback only
at com.atomikos.icatch.jta.TransactionImp.commit(TransactionImp.java:312)
at com.atomikos.icatch.jta.TransactionManagerImp.commit(TransactionManagerImp.java:612)
at com.atomikos.icatch.jta.UserTransactionImp.commit(UserTransactionImp.java:168)
at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1010)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy59.findAllActivitiesByDay(Unknown Source)

加载中
0
hackpro
hackpro

今天我也遇见这样的问题,楼主解决了吗

 

wenwen1
wenwen1
没有
wenwen1
wenwen1
没有
返回顶部
顶部