资源简介
该源码包含Spring整合Jersey,接管Jpa的实现,能够实现与前端页面的交互,可以实现Jersey单元测试。
代码片段和文件信息
package com.spring.jersy.jpa.hibernate.dao;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.orm.hibernate4.HibernateTemplate;
import org.springframework.stereotype.Repository;
import com.spring.jersy.jpa.hibernate.model.User;
//@Repository(value=“userDao“)
public class UserDao {
/* @Resource(name=“hibernateTemplate“)
private HibernateTemplate hibernateTemplate;
//根据用户名和密码查询
public List findByNameAndPassword (User user) {
String queryString = “from User where username = :username and password = :password“;
String paramNames[] = {“username“ “password“};
String paramValues[] = {user.getUsername()user.getPassword()};
@SuppressWarnings(“unchecked“)
List listUsers = (List) hibernateTemplate.findByNamedParam(queryString paramNames paramValues);
return listUsers;
}
@SuppressWarnings(“unchecked“)
public List findUserByName(String name) {
List userList = new ArrayList();
String queryString = “from User where username like:name“;
userList = (List) hibernateTemplate.findByNamedParam(queryString“name“name);
return userList;
}
public boolean addUser(User user) {
try {
hibernateTemplate.save(user);
} catch (Exception e) {
return false;
}
return true;
}
public boolean deleteUser(Integer id) {
try {
User user = hibernateTemplate.get(User.class id);
hibernateTemplate.delete(user);
} catch (Exception e) {
return false;
}
return true;
}
public boolean updateUser(User user){
try {
User updateUser = hibernateTemplate.get(User.class user.getId());
updateUser.setUsername(user.getUsername());
updateUser.setPassword(user.getPassword());
updateUser.setAddress(user.getAddress());
updateUser.setTel(user.getTel());
hibernateTemplate.update(updateUser);
} catch (Exception e) {
return false;
}
return true;
}
public HibernateTemplate getHibernateTemplate() {
return hibernateTemplate;
}
public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
this.hibernateTemplate = hibernateTemplate;
}*/
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-03-29 19:49 Spring+Jersey+JPA+Hibernate+MySQL\
目录 0 2016-03-29 19:48 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\
文件 638 2016-03-25 09:15 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.classpath
目录 0 2016-03-29 19:48 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.myeclipse\
文件 323 2016-03-29 14:31 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.myme
文件 1933 2016-03-24 15:49 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.project
目录 0 2016-03-29 19:48 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.settings\
文件 508 2016-03-22 15:09 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.settings\.jsdtscope
文件 169 2016-03-24 10:49 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.settings\com.genuitec.eclipse.core.prefs
文件 1065 2016-03-24 15:52 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.settings\com.genuitec.eclipse.j2eedt.core.prefs
文件 150 2016-03-25 11:12 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.settings\com.genuitec.eclipse.persistence.jpa.prefs
文件 120 2016-03-24 15:52 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.settings\com.genuitec.jboss.ide.eclipse.xdoclet.run.prefs
文件 93 2016-03-22 15:09 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.settings\org.eclipse.core.resources.prefs
文件 128 2016-03-23 15:44 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.settings\org.eclipse.jdt.core.prefs
文件 108 2016-03-24 16:22 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.settings\org.eclipse.jpt.core.prefs
文件 121 2016-03-22 15:09 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.settings\org.eclipse.m2e.core.prefs
文件 613 2016-03-24 15:52 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.settings\org.eclipse.wst.common.component
文件 346 2016-03-24 16:22 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2016-03-22 15:09 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2016-03-22 15:09 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\.settings\org.eclipse.wst.jsdt.ui.superType.name
文件 8816 2016-03-29 17:54 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\pom.xm
目录 0 2016-03-29 19:48 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\src\
目录 0 2016-03-29 19:48 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\src\main\
目录 0 2016-03-29 19:48 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\src\main\java\
目录 0 2016-03-29 19:48 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\src\main\java\com\
目录 0 2016-03-29 19:48 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\src\main\java\com\spring\
目录 0 2016-03-29 19:48 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\src\main\java\com\spring\jersy\
目录 0 2016-03-29 19:48 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\src\main\java\com\spring\jersy\jpa\
目录 0 2016-03-29 19:48 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\src\main\java\com\spring\jersy\jpa\hibernate\
目录 0 2016-03-29 19:48 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\src\main\java\com\spring\jersy\jpa\hibernate\dao\
文件 2293 2016-03-25 17:07 Spring+Jersey+JPA+Hibernate+MySQL\springjersyjpa\src\main\java\com\spring\jersy\jpa\hibernate\dao\UserDao.java
............此处省略241个文件信息
评论
共有 条评论