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();
}
}
}
阅读(717) | 评论(0) | 转发(0) |