package com.pas.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.pas.dao.UserTypeDao;
import com.pas.model.UserType;

public class UserTypeDaoImpl implements UserTypeDao {
	@Autowired
	private SessionFactory session;
	
	@Override
	public void add(UserType userType) {
		session.getCurrentSession().save(userType);
	}

	@Override
	public void edit(UserType userType) {
		session.getCurrentSession().update(userType);
	}
	
	@Override
	public void delete(int userTypeId) {
		session.getCurrentSession().delete(userTypeId);
	}
	
	@Override
	public UserType getUserType(int userTypeId) {
		return (UserType) session.getCurrentSession().get(UserType.class, userTypeId);
	}
	
	@Override
	public List<UserType> getAllUserType() {
		return (List<UserType>) session.getCurrentSession().createQuery("from " + UserType.class.getName()).list();
	}
}