<commit_before>package com.klaster.webstore.domain.repository.impl;

import com.klaster.webstore.domain.Product;
import com.klaster.webstore.domain.repository.ProductRepository;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import java.util.List;

/**
 * Created by <NAME> on 2017-09-09.
 */
@Repository("ProductRepository")
public class ProductRepositoryImpl implements ProductRepository {

    @Autowired
    private SessionFactory sessionFactory;

    @Override
    public void create(Product product){
        sessionFactory.getCurrentSession().saveOrUpdate(product);
    }

    @Override
    public Product read(long productId){
        return (Product) sessionFactory.getCurrentSession().get(Product.class, productId);
    }

    @Override
    public void delete(Product product) {
        sessionFactory.getCurrentSession().createQuery("DELETE FROM products WHERE productId = "+product.getProductId()).executeUpdate();
    }

    @SuppressWarnings("unchecked")
    @Transactional
    public List<Product> getAllProducts() {
        return (List<Product>) sessionFactory.getCurrentSession().createCriteria(Product.class).list();
        // Create CriteriaBuilder
    //    CriteriaQuery<Product> cq = sessionFactory.getCriteriaBuilder().createQuery(Product.class);
      //  cq.from(Product.class);
     //  return (List<Product>) sessionFactory.createEntityManager(cq).getResultList();
    }

    //TODO Dodac implementacje UPDATE
}
<commit_msg>Addred exception if product not found<commit_after>package com.klaster.webstore.domain.repository.impl;

import com.klaster.webstore.domain.Product;
import com.klaster.webstore.domain.repository.ProductRepository;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import java.util.List;

/**
 * Created by <NAME> on 2017-09-09.
 */
@Repository("ProductRepository")
public class ProductRepositoryImpl implements ProductRepository {

    @Autowired
    private SessionFactory sessionFactory;

    @Override
    public void create(Product product){
        sessionFactory.getCurrentSession().saveOrUpdate(product);
    }

    @Override
    public Product read(long productId){
        //  return (Product) sessionFactory.getCurrentSession().get(Product.class, productId);
        Product product = sessionFactory.getCurrentSession().get(Product.class, productId);
        if(product==null) throw new IllegalArgumentException("Brak produktu o wskazanym id: "+ productId);
        else return product;
    }

    @Override
    public void delete(Product product) {
        sessionFactory.getCurrentSession().createQuery("DELETE FROM products WHERE productId = "+product.getProductId()).executeUpdate();
    }

    @SuppressWarnings("unchecked")
    @Transactional
    public List<Product> getAllProducts() {
        return (List<Product>) sessionFactory.getCurrentSession().createCriteria(Product.class).list();
        // Create CriteriaBuilder
    //    CriteriaQuery<Product> cq = sessionFactory.getCriteriaBuilder().createQuery(Product.class);
      //  cq.from(Product.class);
     //  return (List<Product>) sessionFactory.createEntityManager(cq).getResultList();
    }


    //TODO Dodac implementacje UPDATE
}

{'fraction_non_alphanumeric': 0.10537692515536341, 'fraction_numerical': 0.004323155903809781, 'mean_word_length': 4.558558558558558, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3527180', 'n_tokens_mistral': 962, 'n_tokens_neox': 953, 'n_words': 185}