<commit_before>package com.revature.orderys.dao;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.revature.orderys.bean.Business;
import com.revature.orderys.bean.User;
import com.revature.orderys.util.EasyLogger;

@Transactional
@Repository
public class BusinessDaoImpl implements BusinessDao, Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -6135498789649615155L;
	private EasyLogger logger = new EasyLogger();
	private SessionFactory sessionFactory;
	
	
	public BusinessDaoImpl() {
		super();
	}
	

	public void setSessionFactory(SessionFactory sessionFactory) {
	  this.sessionFactory = sessionFactory;
	}
	
	@Override
	@SuppressWarnings("unchecked")
	public List<Business> getAllBusinesses() {
		List<Business> businesses = new ArrayList<Business>();
		Session session = sessionFactory.getCurrentSession();
		try {
			businesses = (List<Business>) session.createCriteria(Business.class).list();
		} catch (HibernateException ex) {
			logger.catching(ex);
		}
		return businesses;
	}
	
	@Override
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED)
	public void createBusiness(Business b) {
		try {
			Session session = sessionFactory.getCurrentSession();
			session.save(b);
		} catch (HibernateException ex) {
			logger.catching(ex);
		}
	}
	
	@Override
	public Business getBusinessById(long id) {
		Session session = sessionFactory.getCurrentSession();
		return (Business) session.get(Business.class,id);
	}
	
	@Override
	public Business getBusinessByManager(User m) {
		return null;
	}
	
	@Override
	public void updateBusiness(Business b) {<commit_msg>implemented getbusinessbymanager in businessdaoimpl<commit_after>package com.revature.orderys.dao;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.revature.orderys.bean.Business;
import com.revature.orderys.bean.User;
import com.revature.orderys.util.EasyLogger;

@Transactional
@Repository
public class BusinessDaoImpl implements BusinessDao, Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -6135498789649615155L;
	private EasyLogger logger = new EasyLogger();
	private SessionFactory sessionFactory;
	
	
	public BusinessDaoImpl() {
		super();
	}
	

	public void setSessionFactory(SessionFactory sessionFactory) {
	  this.sessionFactory = sessionFactory;
	}
	
	@Override
	@SuppressWarnings("unchecked")
	public List<Business> getAllBusinesses() {
		List<Business> businesses = new ArrayList<Business>();
		Session session = sessionFactory.getCurrentSession();
		try {
			businesses = (List<Business>) session.createCriteria(Business.class).list();
		} catch (HibernateException ex) {
			logger.catching(ex);
		}
		return businesses;
	}
	
	@Override
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED)
	public void createBusiness(Business b) {
		try {
			Session session = sessionFactory.getCurrentSession();
			session.save(b);
		} catch (HibernateException ex) {
			logger.catching(ex);
		}
	}
	
	@Override
	public Business getBusinessById(long id) {
		Session session = sessionFactory.getCurrentSession();
		return (Business) session.get(Business.class,id);
	}
	
	@Override
	public Business getBusinessByManager(User m) {
		Session session = sessionFactory.getCurrentSession();
		Business business = new Business();
		try {
			business = (Business) session.createQuery("from Business b where b.user.id="+m.getId()).list();
		} catch (HibernateException ex) {
			logger.catching(ex);
		}
		return business;
	}
	
	@Override
	public void updateBusiness(Business b) {
{'fraction_non_alphanumeric': 0.10203592814371258, 'fraction_numerical': 0.00910179640718563, 'mean_word_length': 5.414746543778802, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2561432', 'n_tokens_mistral': 1343, 'n_tokens_neox': 1200, 'n_words': 256}