Search in sources :

Example 6 with User

use of com.zsm.ssh.model.User in project Resource by lovelifeming.

the class UserDaoImpl method getByNo.

@Override
@Transactional(propagation = Propagation.REQUIRED)
public User getByNo(String no) {
    Session session = sessionFactory.getCurrentSession();
    List users = session.createQuery("from User where user_no='" + no + "'").list();
    return (User) users.get(0);
}
Also used : User(com.zsm.ssh.model.User) List(java.util.List) Session(org.hibernate.Session) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with User

use of com.zsm.ssh.model.User in project Resource by lovelifeming.

the class UserDaoImplTest method saveEntity.

@Test
public void saveEntity() throws Exception {
    User user = getUser();
    Integer id = userDao.saveEntity(user);
    Assert.assertTrue(id > 8);
}
Also used : User(com.zsm.ssh.model.User) Test(org.junit.Test)

Example 8 with User

use of com.zsm.ssh.model.User in project Resource by lovelifeming.

the class UserDaoImplTest method getByName.

@Test
public void getByName() throws Exception {
    User user = userDao.getByName("杜玉萍");
    Assert.assertEquals("113", user.getUser_no());
}
Also used : User(com.zsm.ssh.model.User) Test(org.junit.Test)

Example 9 with User

use of com.zsm.ssh.model.User in project Resource by lovelifeming.

the class UserDaoImplTest method getUser.

private User getUser() throws ParseException {
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    User user = new User();
    user.setUser_name("李元芳");
    user.setUser_no("114");
    user.setPassword("efafa13");
    user.setUser_sex("男");
    Date bir = formatter.parse("1990-06-03 00:00:00");
    user.setUser_birthday(bir);
    user.setUser_class("95035");
    Date cur = new Date();
    user.setCreatetime(cur);
    cur.setDate(-1);
    user.setUpdatetime(cur);
    return user;
}
Also used : User(com.zsm.ssh.model.User) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 10 with User

use of com.zsm.ssh.model.User in project Resource by lovelifeming.

the class UserDaoImplTest method updateEntity.

@Test
public void updateEntity() throws Exception {
    User user = getUser();
    user.setId(10);
    userDao.saveEntity(user);
}
Also used : User(com.zsm.ssh.model.User) Test(org.junit.Test)

Aggregations

User (com.zsm.ssh.model.User)12 Test (org.junit.Test)6 Session (org.hibernate.Session)4 Transactional (org.springframework.transaction.annotation.Transactional)4 List (java.util.List)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 JSONObject (net.sf.json.JSONObject)1 Action (org.apache.struts2.convention.annotation.Action)1