/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package me.ronghai.sa.engine.service.impl;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import me.ronghai.sa.dao.ClientDAO;
import me.ronghai.sa.engine.service.ClientService;
import me.ronghai.sa.model.Client;

/**
 *
 * @author ronghai
 */
public class ClientServiceImpl implements ClientService, Serializable {

    private static final long serialVersionUID = 1L;
    private ClientDAO clientDAO;

    public ClientDAO getClientDAO() {
        return clientDAO;
    }

    public void setClientDAO(ClientDAO clientDAO) {
        this.clientDAO = clientDAO;
    }

    @Override
    public Client update(Client entity) {
        return clientDAO.update(entity);
    }

    @Override
    public Client find(Object id) {
        return clientDAO.find(id);
    }

    @Override
    public List<Client> find() {
        return clientDAO.find(" WHERE disabled = false ");
    }
    @Override
    public void remove(Client c){
        this.clientDAO.remove(c, false);
    }
    @Override
    public void remove(Long ... ids){
        for(Long id : ids){
            this.clientDAO.remove(this.clientDAO.find(id), false);
        }
    }
    
    
    @Override
    public void remove(Collection<Long> ids){
        for(Long id : ids){
            this.clientDAO.remove(this.clientDAO.find(id), false);
        }
    }
    
    @Override
    public Client save(Client c){
        this.clientDAO.persistent(c);
        return c;
    }

}

@@ -251,16 +251,41 @@
 izable;%0A
+import java.util.Arrays;%0A
 import j
@@ -449,16 +449,144 @@
 .Client;
+%0Aimport org.springframework.transaction.annotation.Propagation;%0Aimport org.springframework.transaction.annotation.Transactional;
 %0A%0A/**%0A *
@@ -927,32 +927,118 @@
 ientDAO;%0A    %7D%0A%0A
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)%0A
     @Override%0A  
@@ -1321,32 +1321,123 @@
 false %22);%0A    %7D%0A
+    %0A    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)%0A
     @Override%0A  
@@ -1524,154 +1524,200 @@
    @
-Override%0A    public void remove(Long ... ids)%7B%0A        for(Long id : ids)%7B%0A            this.clientDAO.remove(this.clientDAO.find(id), false);%0A    
+Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)%0A    @Override%0A    public void remove(Long ... ids)%7B%0A       this.clientDAO.remove( false,  Arrays.asList(ids));%0A
     
@@ -1726,195 +1726,295 @@
     
-%7D
 %0A    
-%0A    %0A    @Override%0A    public void remove(Collection%3CLong%3E ids)%7B%0A        for(Long id : ids)%7B%0A            this.clientDAO.remove(this.clientDAO.find(id), false);%0A        %7D%0A    %7D%0A    
+@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)%0A    @Override%0A    public void remove(Collection%3CLong%3E ids)%7B%0A        this.clientDAO.remove( false, ids);%0A    %7D%0A    %0A    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 %0A   

fix issues