后台代码如下:
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)
今天我也遇见这样的问题,楼主解决了吗
没有没有
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。