package com.dao;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;

import com.entities.Seller;



public class SellerDao {
	private SessionFactory factory;

	public SellerDao(SessionFactory factory) {
		super();
		this.factory = factory;
	}
	
	public Seller getUserByEmailAndPassword(String email, String password) {
		Seller seller= null;
		
		try {
			
			String query = "from Seller where sellerEmail =: e and sellerPassword =: p";
			Session session = this.factory.openSession();
			Query<?> q = session.createQuery(query);
			q.setParameter("e", email);
			q.setParameter("p", password);
			
			seller = (Seller)q.uniqueResult();
			
			session.close();
			
			
			
			
		}catch(Exception e) {
			e.printStackTrace();
		}
		return seller;
	}


}
