package com.totsp.example.jpa.dao.spring; import java.util.List; import org.springframework.orm.jpa.support.JpaDaoSupport; import com.totsp.example.jpa.dao.IUserDao; import com.totsp.example.jpa.exception.DataException; import com.totsp.example.jpa.model.User; public class UserDao extends JpaDaoSupport implements IUserDao { public User get(long id) throws DataException { return getJpaTemplate().find(User.class, id); } public User get(String name) throws DataException { // TODO return one //return getJpaTemplate().find("select a from User a where a.name = ?1", name); return null; } public List getAll() throws DataException { return getJpaTemplate().find("select a from User a"); } public void save(User obj) throws DataException { getJpaTemplate().persist(obj); } public User update(User obj) throws DataException { return getJpaTemplate().merge(obj); } public void remove(User obj) throws DataException { getJpaTemplate().remove(obj); } }