Chinaunix首页 | 论坛 | 博客
  • 博客访问: 475478
  • 博文数量: 111
  • 博客积分: 3146
  • 博客等级: 中校
  • 技术积分: 939
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-07 11:23
个人简介

Nathing

文章分类

全部博文(111)

文章存档

2016年(2)

2015年(1)

2014年(31)

2012年(2)

2011年(9)

2010年(36)

2009年(30)

我的朋友

分类: Java

2010-05-27 22:46:48

package com.my.shop.service.product;
import com.my.shop.dao.DAO;
public interface ProductTypeService extends DAO
{
}
 
 
 
package com.my.shop.service.product.impl;
import javax.persistence.Query;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.my.shop.dao.DaoSupport;
import com.my.shop.service.product.ProductTypeService;
@Service
@Transactional
public class ProductTypeServiceImpl extends DaoSupport implements ProductTypeService
{
 @Override
 public void delete(Class entityClass, Object[] entityIds)
 {
  //update ProductType o set o.visible=?1 where o.typeId in(?2,?3,?4,...)"
  if(entityIds !=null && entityIds.length>0)
  {
   StringBuffer jpql = new StringBuffer();
   for(int i=0; i   {
    jpql.append("?").append(i+2).append(",");
   }
   jpql.deleteCharAt(jpql.length()-1);
   
   Query query = em.createQuery("update ProductType o set o.visible=?1 where o.typeId in("+ jpql.toString() +")")
   .setParameter(1, false);
   for(int i=0; i   {
    query.setParameter(i+2, entityIds[i]);
   }
   query.executeUpdate();
  }
  
 }
}
阅读(670) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~