启用springOpenEntityManagerInViewFilter更新实体日志记录

/**产品修改*/
public ActionForward edit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
ProductForm formbean=(ProductForm)form;
FormValidate formValidate= new FormValidate(request);
formValidate.addValidateItem(new ValidateItem("name","产品名称不能为空",new NotBlank()));
formValidate.addValidateItem(new ValidateItem("name","产品名称不能大于50个字", new LengthBetween(1,50)));
formValidate.addValidateItem(new ValidateItem("typeid","产品类别不能为空",new NotBlank()));
formValidate.validateServer();
if(!formValidate.isFormServerValidated()){//服务器端验证
request.setAttribute("errors", true);
request.setAttribute("errorMessage", formValidate.serverErrors());
return new ActionForward("/control/product/manage.do?method=editUI&productid="+formbean.getProductid());
}
Product product =productService.find(formbean.getProductid());
product.setBaseprice(formbean.getBaseprice());
product.setBuyexplain(formbean.getBuyexplain());
product.setCode(formbean.getCode());
product.setDescription(formbean.getDescription());
product.setMarketprice(formbean.getMarketprice());
product.setModel(formbean.getModel());
product.setName(formbean.getName());
product.setSellprice(formbean.getSellprice());
product.setSexrequest(Sex.valueOf(formbean.getSex()));
product.setWeight(formbean.getWeight());
if(!StringUtils.isEmpty(formbean.getBrandid())){
product.setProductbrand(new ProductBrand(formbean.getBrandid()));
}
product.setProducttype(new ProductType(formbean.getTypeid()));
try{
productService.doNone();//此时product处于托管状态,启动事务并提交会自动回到数据库。
}catch(Exception ex){
ex.printStackTrace();
request.setAttribute("errors", true);
request.setAttribute("errorMessage", "产品修改失败");
return new ActionForward("/control/product/manage.do?method=editUI&productid="+formbean.getProductid());
}
request.setAttribute("message", "产品修改成功");
request.setAttribute("urladdress", "/control/product/list.do");
return mapping.findForward("message");
}
代码对应的日志

2012-06-07 19:15:43,883 DEBUG (org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter:146) - Using EntityManagerFactory 'entityManagerFactory' for OpenEntityManagerInViewFilter
2012-06-07 19:15:43,883 DEBUG (org.springframework.beans.factory.support.DefaultListableBeanFactory:214) - Returning cached instance of singleton bean 'entityManagerFactory'
2012-06-07 19:15:43,883 DEBUG (org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter:101) - Opening JPA EntityManager in OpenEntityManagerInViewFilter
2012-06-07 19:15:43,884 DEBUG (org.springframework.transaction.support.TransactionSynchronizationManager:186) - Bound value [org.springframework.orm.jpa.EntityManagerHolder@e2d858] for key [org.springframework.orm.jpa.LocalEntityManagerFactoryBean@537d55] to thread [http-80-Processor22]
2012-06-07 19:15:43,933 DEBUG (org.springframework.web.struts.DelegatingActionUtils:166) - DelegatingActionProxy with mapping path '/control/product/manage' and module prefix '' delegating to Spring bean with name [/control/product/manage]
2012-06-07 19:15:43,933 DEBUG (org.springframework.beans.factory.support.DefaultListableBeanFactory:214) - Returning cached instance of singleton bean '/control/product/manage'
2012-06-07 19:15:43,943 DEBUG (org.springframework.transaction.support.TransactionSynchronizationManager:142) - Retrieved value [org.springframework.orm.jpa.EntityManagerHolder@e2d858] for key [org.springframework.orm.jpa.LocalEntityManagerFactoryBean@537d55] bound to thread [http-80-Processor22]
2012-06-07 19:15:43,943 DEBUG (org.springframework.orm.jpa.JpaTransactionManager:285) - Found thread-bound EntityManager [org.hibernate.ejb.EntityManagerImpl@1649b1a] for JPA transaction
2012-06-07 19:15:43,943 DEBUG (org.springframework.transaction.support.TransactionSynchronizationManager:261) - Initializing transaction synchronization
2012-06-07 19:15:43,944 DEBUG (org.springframework.transaction.interceptor.TransactionInterceptor:290) - Getting transaction for [net.risesoft.service.base.Dao.find]
2012-06-07 19:15:43,944 DEBUG (org.springframework.transaction.support.TransactionSynchronizationManager:142) - Retrieved value [org.springframework.orm.jpa.EntityManagerHolder@e2d858] for key [org.springframework.orm.jpa.LocalEntityManagerFactoryBean@537d55] bound to thread [http-80-Processor22]
2012-06-07 19:15:43,945 DEBUG (org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler:416) - Starting resource local transaction on application-managed EntityManager [org.hibernate.ejb.EntityManagerImpl@1649b1a]
2012-06-07 19:15:43,945 DEBUG (org.springframework.transaction.support.TransactionSynchronizationManager:186) - Bound value [org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerSynchronization@2e879] for key [org.hibernate.ejb.EntityManagerImpl@1649b1a] to thread [http-80-Processor22]
2012-06-07 19:15:43,946 DEBUG (org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler:393) - Joined local transaction
Hibernate: select product0_.id as id4_3_, product0_.baseprice as baseprice4_3_, product0_.buyexplain as buyexplain4_3_, product0_.clickcount as clickcount4_3_, product0_.code as code4_3_, product0_.commend as commend4_3_, product0_.createDate as createDate4_3_, product0_.description as descript8_4_3_, product0_.marketprice as marketpr9_4_3_, product0_.model as model4_3_, product0_.name as name4_3_, product0_.productbrandId as product17_4_3_, product0_.producttypeid as product18_4_3_, product0_.sellcount as sellcount4_3_, product0_.sellprice as sellprice4_3_, product0_.sexrequest as sexrequest4_3_, product0_.visible as visible4_3_, product0_.weight as weight4_3_, productbra1_.code as code5_0_, productbra1_.logopath as logopath5_0_, productbra1_.name as name5_0_, productbra1_.visible as visible5_0_, producttyp2_.typeid as typeid10_1_, producttyp2_.name as name10_1_, producttyp2_.note as note10_1_, producttyp2_.parentid as parentid10_1_, producttyp2_.visible as visible10_1_, producttyp3_.typeid as typeid10_2_, producttyp3_.name as name10_2_, producttyp3_.note as note10_2_, producttyp3_.parentid as parentid10_2_, producttyp3_.visible as visible10_2_ from product product0_ left outer join productbrand productbra1_ on product0_.productbrandId=productbra1_.code inner join productType producttyp2_ on product0_.producttypeid=producttyp2_.typeid left outer join productType producttyp3_ on producttyp2_.parentid=producttyp3_.typeid where product0_.id=?
2012-06-07 19:15:43,949 DEBUG (org.springframework.transaction.interceptor.TransactionInterceptor:319) - Completing transaction for [net.risesoft.service.base.Dao.find]
2012-06-07 19:15:43,950 DEBUG (org.springframework.orm.jpa.JpaTransactionManager:903) - Triggering beforeCommit synchronization
2012-06-07 19:15:43,950 DEBUG (org.springframework.orm.jpa.JpaTransactionManager:916) - Triggering beforeCompletion synchronization
2012-06-07 19:15:43,950 DEBUG (org.springframework.transaction.support.TransactionSynchronizationManager:232) - Removed value [org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerSynchronization@2e879] for key [org.hibernate.ejb.EntityManagerImpl@1649b1a] from thread [http-80-Processor22]
2012-06-07 19:15:43,950 DEBUG (org.springframework.orm.jpa.JpaTransactionManager:929) - Triggering afterCommit synchronization
2012-06-07 19:15:43,952 DEBUG (org.springframework.orm.jpa.JpaTransactionManager:945) - Triggering afterCompletion synchronization
2012-06-07 19:15:43,952 DEBUG (org.springframework.transaction.support.TransactionSynchronizationManager:315) - Clearing transaction synchronization
2012-06-07 19:15:43,957 DEBUG (org.springframework.transaction.annotation.AnnotationTransactionAttributeSource:107) - Adding transactional method [doNone] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
2012-06-07 19:15:43,958 DEBUG (org.springframework.transaction.support.TransactionSynchronizationManager:142) - Retrieved value [org.springframework.orm.jpa.EntityManagerHolder@e2d858] for key [org.springframework.orm.jpa.LocalEntityManagerFactoryBean@537d55] bound to thread [http-80-Processor22]
2012-06-07 19:15:43,958 DEBUG (org.springframework.orm.jpa.JpaTransactionManager:285) - Found thread-bound EntityManager [org.hibernate.ejb.EntityManagerImpl@1649b1a] for JPA transaction
2012-06-07 19:15:43,958 DEBUG (org.springframework.orm.jpa.JpaTransactionManager:371) - Creating new transaction with name [net.risesoft.service.base.Dao.doNone]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2012-06-07 19:15:43,959 DEBUG (org.springframework.transaction.support.TransactionSynchronizationManager:261) - Initializing transaction synchronization
2012-06-07 19:15:43,959 DEBUG (org.springframework.transaction.interceptor.TransactionInterceptor:290) - Getting transaction for [net.risesoft.service.base.Dao.doNone]
DaoSupport doNone
2012-06-07 19:15:43,959 DEBUG (org.springframework.transaction.interceptor.TransactionInterceptor:319) - Completing transaction for [net.risesoft.service.base.Dao.doNone]
2012-06-07 19:15:43,959 DEBUG (org.springframework.orm.jpa.JpaTransactionManager:903) - Triggering beforeCommit synchronization
2012-06-07 19:15:43,960 DEBUG (org.springframework.orm.jpa.JpaTransactionManager:916) - Triggering beforeCompletion synchronization
2012-06-07 19:15:43,960 DEBUG (org.springframework.orm.jpa.JpaTransactionManager:730) - Initiating transaction commit
2012-06-07 19:15:43,960 DEBUG (org.springframework.orm.jpa.JpaTransactionManager:451) - Committing JPA transaction on EntityManager [org.hibernate.ejb.EntityManagerImpl@1649b1a]
Hibernate: select productbra_.code, productbra_.logopath as logopath5_, productbra_.name as name5_, productbra_.visible as visible5_ from productbrand productbra_ where productbra_.code=?
Hibernate: update product set baseprice=?, buyexplain=?, clickcount=?, code=?, commend=?, createDate=?, description=?, marketprice=?, model=?, name=?, productbrandId=?, producttypeid=?, sellcount=?, sellprice=?, sexrequest=?, visible=?, weight=? where id=?
2012-06-07 19:15:44,034 DEBUG (org.springframework.orm.jpa.JpaTransactionManager:929) - Triggering afterCommit synchronization
2012-06-07 19:15:44,035 DEBUG (org.springframework.orm.jpa.JpaTransactionManager:945) - Triggering afterCompletion synchronization
2012-06-07 19:15:44,035 DEBUG (org.springframework.transaction.support.TransactionSynchronizationManager:315) - Clearing transaction synchronization
2012-06-07 19:15:44,035 DEBUG (org.springframework.orm.jpa.JpaTransactionManager:539) - Not closing pre-bound JPA EntityManager after transaction
message.jsp2012-06-07 19:15:44,099 DEBUG (org.springframework.transaction.support.TransactionSynchronizationManager:232) - Removed value [org.springframework.orm.jpa.EntityManagerHolder@e2d858] for key [org.springframework.orm.jpa.LocalEntityManagerFactoryBean@537d55] from thread [http-80-Processor22]
2012-06-07 19:15:44,100 DEBUG (org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter:119) - Closing JPA EntityManager in OpenEntityManagerInViewFilter
2012-06-07 19:15:44,100 DEBUG (org.springframework.orm.jpa.EntityManagerFactoryUtils:313) - Closing JPA EntityManager

你可能感兴趣的:(spring,Web,Hibernate,struts,jpa)