All Downloads are FREE. Search and download functionalities are using the official Maven repository.

in.cleartax.dropwizard.sharding.dao.CustomerDao Maven / Gradle / Ivy

There is a newer version: 0.2.198
Show newest version
package in.cleartax.dropwizard.sharding.dao;

import in.cleartax.dropwizard.sharding.entities.Customer;
import io.dropwizard.hibernate.AbstractDAO;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;

import javax.inject.Inject;
import javax.inject.Named;

/**
 * Created on 02/11/18
 */
public class CustomerDao extends AbstractDAO {
    /**
     * Creates a new DAO with a given session provider.
     *
     * @param sessionFactory a session provider
     */
    @Inject
    public CustomerDao(@Named("session") SessionFactory sessionFactory) {
        super(sessionFactory);
    }

    public Customer getByUserName(String userName) {
        Criteria criteria = criteria().add(Restrictions.eq("userName", userName));
        return (Customer) criteria.uniqueResult();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy