Example usage for org.hibernate.criterion DetachedCriteria forClass

List of usage examples for org.hibernate.criterion DetachedCriteria forClass

Introduction

In this page you can find the example usage for org.hibernate.criterion DetachedCriteria forClass.

Prototype

public static DetachedCriteria forClass(Class clazz) 

Source Link

Document

Static builder to create a DetachedCriteria for the given entity, by its Class.

Usage

From source file:com.apress.progwt.server.dao.hibernate.UserDAOHibernateImpl.java

License:Apache License

public User getUserByNicknameFetchAll(String nickname) {

    return fetchAllUser(
            DetachedCriteria.forClass(User.class).add(Expression.eq("nickname", nickname.toLowerCase())));
}

From source file:com.apress.progwt.server.dao.hibernate.UserDAOHibernateImpl.java

License:Apache License

public User getUserByUsernameFetchAll(String username) {
    return fetchAllUser(DetachedCriteria.forClass(User.class).add(Expression.eq("username", username)));
}

From source file:com.ateam.hibernate.HibernateDAOImpl.java

public UserAttr checkUser(String strUserName) throws DataAccessException, java.sql.SQLException {
    UserAttr obj = null;/*  ww  w  .  j  a v  a  2s .  c om*/
    DetachedCriteria critone = DetachedCriteria.forClass(UserAttr.class);
    critone.add(Restrictions.eq("userName", strUserName));

    List objs = getHibernateTemplate().findByCriteria(critone);
    if ((objs != null) && (objs.size() > 0)) {
        obj = (UserAttr) objs.get(0);
    }
    return obj;
}

From source file:com.ateam.hibernate.HibernateDAOImpl.java

public UserAttr validateUser(String strUserName, String password)
        throws DataAccessException, java.sql.SQLException {
    UserAttr obj = null;//from w  ww.j  a v  a2  s.co  m
    DetachedCriteria crittwo = DetachedCriteria.forClass(UserAttr.class);
    crittwo.add(Restrictions.eq("userName", strUserName));
    crittwo.add(Restrictions.eq("userPassword", password));
    List objs = getHibernateTemplate().findByCriteria(crittwo);
    if ((objs != null) && (objs.size() > 0)) {
        obj = (UserAttr) objs.get(0);
    }
    return obj;
}

From source file:com.ateam.hibernate.HibernateDAOImpl.java

public String checkRole(String strUserName, String password) throws DataAccessException, java.sql.SQLException {
    String obj = null;/*from  ww  w. j  a  v  a2  s. c  om*/
    DetachedCriteria critthree = DetachedCriteria.forClass(UserAttr.class);
    ProjectionList pl = Projections.projectionList();
    pl.add(Projections.groupProperty("userRole"));
    critthree.add(Restrictions.eq("userName", strUserName));
    critthree.add(Restrictions.eq("userPassword", password));
    critthree.setProjection(pl);
    List objs = getHibernateTemplate().findByCriteria(critthree);
    if ((objs != null) && (objs.size() > 0)) {
        obj = (String) objs.get(0);
    }
    return obj;
}

From source file:com.ateam.hibernate.HibernateDAOImpl.java

public String checkFullName(String strUserName, String password)
        throws DataAccessException, java.sql.SQLException {
    String obj = null;/*from  w  ww. j a  v  a2  s. c om*/
    DetachedCriteria critname = DetachedCriteria.forClass(UserAttr.class);
    ProjectionList pl = Projections.projectionList();
    pl.add(Projections.groupProperty("userFullName"));
    critname.add(Restrictions.eq("userName", strUserName));
    critname.add(Restrictions.eq("userPassword", password));
    critname.setProjection(pl);
    List objs = getHibernateTemplate().findByCriteria(critname);
    if ((objs != null) && (objs.size() > 0)) {
        obj = (String) objs.get(0);
    }
    return obj;
}

From source file:com.ateam.hibernate.HibernateDAOImpl.java

public List<Questions> generateQuestion(String skillId, String difficulty)
        throws DataAccessException, java.sql.SQLException {
    Questions obj = null;// w w w .  j  a v a2s  .c om
    DetachedCriteria criteria = DetachedCriteria.forClass(Questions.class);
    criteria.add(Restrictions.eq("skillId", skillId));
    criteria.add(Restrictions.eq("difficulty", difficulty));
    criteria.add(Restrictions.sqlRestriction("1=1 order by rand() LIMIT 1"));
    List objs = getHibernateTemplate().findByCriteria(criteria);
    if ((objs != null) && (objs.size() > 0)) {
        obj = (Questions) objs.get(0);
    }
    return objs;
}

From source file:com.ateam.hibernate.HibernateDAOImpl.java

public void deleteUser(String userName) throws DataAccessException {
    UserAttr obj4 = null;/*from  w ww.j ava2s  . co  m*/
    DetachedCriteria criteria4 = DetachedCriteria.forClass(UserAttr.class);
    criteria4.add(Restrictions.eq("userName", userName));
    List objs = getHibernateTemplate().findByCriteria(criteria4);
    if ((objs != null) && (objs.size() > 0)) {
        obj4 = (UserAttr) objs.get(0);
        getHibernateTemplate().delete(obj4);
    }

}

From source file:com.ateam.hibernate.HibernateDAOImpl.java

public List<UserAttr> listUsers() throws DataAccessException, java.sql.SQLException {
    UserAttr obj = null;//ww  w.j  a v a 2  s.  co m
    DetachedCriteria critfour = DetachedCriteria.forClass(UserAttr.class);
    critfour.setProjection(Projections.property("userName"));
    List objs = getHibernateTemplate().findByCriteria(critfour);

    return objs;
}

From source file:com.ateam.hibernate.HibernateDAOImpl.java

public List<Questions> listSkills() throws DataAccessException, java.sql.SQLException {
    Questions obj = null;//from   ww w  .j a  v  a2 s . c  om
    DetachedCriteria critfive = DetachedCriteria.forClass(Questions.class);
    critfive.setProjection(Projections.distinct(Projections.property("skillId")));
    List objs = getHibernateTemplate().findByCriteria(critfive);

    return objs;
}