@Repository
public class UserDAOImpl implements UserDAO {
@Autowired
private HibernateTemplate hibernateTemplate;
public User QueryByID(String username) {
List list = hibernateTemplate
.find("select user from User user where user.username=‘"
+ username + "‘");
if (list.size() == 0) {
return null;
} else {
User user = (User) list.get(0);
return user;
}
}
public void addUser(User user) {
hibernateTemplate.save(user);
}