Example usage for org.hibernate.type CustomType CustomType

List of usage examples for org.hibernate.type CustomType CustomType

Introduction

In this page you can find the example usage for org.hibernate.type CustomType CustomType.

Prototype

public CustomType(UserType userType) throws MappingException 

Source Link

Usage

From source file:org.efs.openreports.providers.impl.UserProviderImpl.java

License:Open Source License

public ReportUser getUser(String name, String password) throws ProviderException {
    try {//w  w  w. ja  v  a  2 s .  com
        Session session = hibernateProvider.openSession();
        try {
            Query query = session.createQuery("from org.efs.openreports.objects.ReportUser as user "
                    + "where user.name = :userName and user.password = :password");
            query.setParameter("userName", name);
            query.setParameter("password", password, new CustomType(new EncryptedStringUserType()));
            //List<ReportUser> list = session.createQuery(
            //      "from org.efs.openreports.objects.ReportUser as user "
            //            + "where user.name = ? and user.password = ?").setString(0, name).setString(1, password).list();               

            //if (list.size() == 0)
            //   return null;

            //ReportUser user = list.get(0);            

            return (ReportUser) query.uniqueResult();
        } catch (HibernateException he) {
            throw he;
        } finally {
            session.close();
        }
    } catch (HibernateException he) {
        throw new ProviderException(he);
    }
}