package com.jh.radegast.rating;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;

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

import com.jh.common.jpa.AbstractHibernateRepository;
import com.jh.radegast.model.Rating;


@Repository
public class RatingRepository extends AbstractHibernateRepository {

	public void saveBulk(Collection<Rating> ratings) {
		if (ratings == null || ratings.isEmpty()) {
			return;
		}
		
		for (Rating r : ratings) {
			save(r);
		}
	}


	public List<Rating> fetchByKeys(Set<String> keySet) {
		if (keySet == null || keySet.isEmpty()) {
			return Collections.emptyList();
		}
		
		return criteria(Rating.class).add(Restrictions.in("key", keySet)).list();
	}
	

}
