<commit_before>package com.KOIFish.FishStock.backend.implementations;

import com.KOIFish.FishStock.backend.FishStockCompanyDAO;
import com.KOIFish.FishStock.beans.FishStockCompany;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class FishStockCompanyDAOImplementation implements FishStockCompanyDAO {

    @Override
    public int getAverageRatingByCompanyId(Session session, int companyId) {
        Criteria criteria = session.createCriteria(FishStockCompany.class);
        criteria.add(Restrictions.eq("companyId", companyId));
        FishStockCompany company = (FishStockCompany) criteria.uniqueResult();
        return company.getTotalRating()/company.getTotalUsersRated();
    }
    public List getAllCompanies(Session session) {
        Criteria criteria = session.createCriteria(FishStockCompany.class);
        return criteria.list();
    }<commit_msg>Created implementation of DAO interface method for getting all Companies<commit_after>package com.KOIFish.FishStock.backend.implementations;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.KOIFish.FishStock.backend.FishStockCompanyDAO;
import com.KOIFish.FishStock.beans.FishStockCompany;

@Repository(value="companyDAO")
public class FishStockCompanyDAOImplementation implements FishStockCompanyDAO {

    @Override
    public int getAverageRatingByCompanyId(Session session, int companyId) {
        Criteria criteria = session.createCriteria(FishStockCompany.class);
        criteria.add(Restrictions.eq("companyId", companyId));
        FishStockCompany company = (FishStockCompany) criteria.uniqueResult();
        return company.getTotalRating()/company.getTotalUsersRated();
    }
    
	@Override
	public Set<FishStockCompany> getAllCompanies(Session session) {
		Criteria criteria = session.createCriteria(FishStockCompany.class);
		return new HashSet<FishStockCompany>(criteria.list());
	}
{'fraction_non_alphanumeric': 0.08786231884057971, 'fraction_numerical': 0.0, 'mean_word_length': 5.594029850746269, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2898460', 'n_tokens_mistral': 658, 'n_tokens_neox': 588, 'n_words': 113}