Package org.jeecgframework.web.demo.entity.test

Examples of org.jeecgframework.web.demo.entity.test.OptimisticLockingEntity


@Transactional
public class OptimisticLockingServiceImpl extends CommonServiceImpl implements OptimisticLockingServiceI {
  public void  dd (){
    Session session1=getSession()
        Session session2=getSession()
        OptimisticLockingEntity stu1=this.get(OptimisticLockingEntity.class, "2c91992b3f74fd05013f74fda0260001");
        OptimisticLockingEntity stu2=this.get(OptimisticLockingEntity.class, "2c91992b3f74fd05013f74fda0260001");
         
        //这时候,两个版本号是相同的 
        org.jeecgframework.core.util.LogUtil.info("v1="+stu1.getVer()+"--v2="+stu2.getVer())
         
        Transaction tx1=session1.beginTransaction()
        stu1.setAccount(200);
        tx1.commit()
        //这时候,两个版本号是不同的,其中一个的版本号递增了 
        org.jeecgframework.core.util.LogUtil.info("v1="+stu1.getVer()+"--v2="+stu2.getVer())
         
        Transaction tx2=session2.beginTransaction()
        stu2.setAccount(500);
         
        tx2.rollback()
        session2.close()
        session1.close();
  }
View Full Code Here


  public AjaxJson save(OptimisticLockingEntity optimisticLocking, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    //optimisticLockingService.dd();
    if (StringUtil.isNotEmpty(optimisticLocking.getId())) {
      message = "更新成功";
      OptimisticLockingEntity t = optimisticLockingService.get(OptimisticLockingEntity.class, optimisticLocking.getId());
      try {
        org.jeecgframework.core.util.LogUtil.info("提交的版本号:"+optimisticLocking.getVer()+",当前版本号:"+t.getVer());
        if(optimisticLocking.getVer()< t.getVer()){
          j.setSuccess(false);
          j.setMsg("提交的数据已过期");
          throw new Exception("提交的数据已过期");
        }
        MyBeanUtils.copyBeanNotNull2Bean(optimisticLocking, t);
View Full Code Here

TOP

Related Classes of org.jeecgframework.web.demo.entity.test.OptimisticLockingEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.