Created
February 26, 2014 09:03
-
-
Save allanruin/9226175 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.irix.service; | |
import java.util.List; | |
import me.irix.dao.BaseDAO; | |
import org.apache.logging.log4j.LogManager; | |
import org.apache.logging.log4j.Logger; | |
import org.apache.logging.log4j.Marker; | |
import org.apache.logging.log4j.MarkerManager; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.stereotype.Service; | |
@Service | |
public class BaseService<T> { | |
private Class<T> clazz; | |
private BaseDAO<T> dao; | |
public BaseDAO<T> getDao() { | |
return dao; | |
} | |
@Autowired | |
public void setDao(BaseDAO<T> dao) { | |
this.dao = dao; | |
} | |
private Logger logger = LogManager.getLogger(BaseDAO.class); | |
private static final Marker DAO_MARKER = MarkerManager.getMarker("SERVICE"); | |
public void save(T instance){ | |
dao.save(instance); | |
} | |
public void delete(T instance){ | |
dao.delete(instance); | |
} | |
@SuppressWarnings("unchecked") | |
public List<T> findById(Integer id){ | |
return (List<T>) dao.findById(id); | |
} | |
public List<T> findAll(){ | |
return (List<T>) dao.findAll(); | |
} | |
public List<T> findAllBeginAt(int begin, int len){ | |
return dao.findAllBeginAt(begin, len); | |
} | |
public List<T> findByExample(T instance){ | |
return dao.findByExample(instance); | |
} | |
public List<T> findByProperty(String s, Object value){ | |
return dao.findByProperty(s, value); | |
} | |
public T merge(T detachedInstance){ | |
return dao.merge(detachedInstance); | |
} | |
public void attachDirty(T instance){ | |
dao.attachDirty(instance); | |
} | |
public void attachClean(T instance){ | |
dao.attachClean(instance); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment