<commit_before>package edu.emory.cci.aiw.cvrg.eureka.etl.dao;

import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.NonUniqueResultException;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.inject.Inject;
import com.google.inject.persist.Transactional;

import edu.emory.cci.aiw.cvrg.eureka.common.entity.Configuration;
import edu.emory.cci.aiw.cvrg.eureka.common.entity.Configuration_;

/**
 * Implementation of the {@link ConfDao} interface, based on JPA.
 *
 * @author hrathod
 *
 */
public class JpaConfDao implements ConfDao {

	/**
	 * The class level logger.
	 */
	private static final Logger LOGGER = LoggerFactory.getLogger(JpaConfDao.class);
	/**
	 * The entity manager used to interact with the data store.
	 */
	private final EntityManager entityManager;

	/**
	 * Creates an object using the given entity manager.
	 *
	 * @param manager The entity manager to use for interaction with the data
	 * store.
	 */
	@Inject
	public JpaConfDao(EntityManager manager) {
		this.entityManager = manager;
	}

	@Override
	@Transactional
	public void save(Configuration conf) {
		this.entityManager.persist(conf);
	}

	@Override
	public Configuration get(Long userId) {
		Configuration configuration = null;
		try {
			CriteriaBuilder builder = this.entityManager.getCriteriaBuilder();
			CriteriaQuery<Configuration> criteriaQuery = builder.createQuery(Configuration.class);
			Root<Configuration> root = criteriaQuery.from(Configuration.class);
			TypedQuery<Configuration> query = this.entityManager.createQuery(criteriaQuery.
					where(builder.equal(root.get(Configuration_.userId), userId)));
			configuration = (Configuration) query.getSingleResult();
		} catch (NoResultException nre) {
			LOGGER.error(nre.getMessage(), nre);
		} catch (NonUniqueResultException nure) {
			LOGGER.error(nure.getMessage(), nure);
		}
		return configuration;
	}
}<commit_msg>Removed spurious cast, which was left over before using the better typed criteria queries.<commit_after>package edu.emory.cci.aiw.cvrg.eureka.etl.dao;

import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.NonUniqueResultException;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.inject.Inject;
import com.google.inject.persist.Transactional;

import edu.emory.cci.aiw.cvrg.eureka.common.entity.Configuration;
import edu.emory.cci.aiw.cvrg.eureka.common.entity.Configuration_;

/**
 * Implementation of the {@link ConfDao} interface, based on JPA.
 *
 * @author hrathod
 *
 */
public class JpaConfDao implements ConfDao {

	/**
	 * The class level logger.
	 */
	private static final Logger LOGGER = LoggerFactory.getLogger(JpaConfDao.class);
	/**
	 * The entity manager used to interact with the data store.
	 */
	private final EntityManager entityManager;

	/**
	 * Creates an object using the given entity manager.
	 *
	 * @param manager The entity manager to use for interaction with the data
	 * store.
	 */
	@Inject
	public JpaConfDao(EntityManager manager) {
		this.entityManager = manager;
	}

	@Override
	@Transactional
	public void save(Configuration conf) {
		this.entityManager.persist(conf);
	}

	@Override
	public Configuration get(Long userId) {
		Configuration configuration = null;
		try {
			CriteriaBuilder builder = this.entityManager.getCriteriaBuilder();
			CriteriaQuery<Configuration> criteriaQuery = builder.createQuery(Configuration.class);
			Root<Configuration> root = criteriaQuery.from(Configuration.class);
			TypedQuery<Configuration> query = this.entityManager.createQuery(criteriaQuery.
					where(builder.equal(root.get(Configuration_.userId), userId)));
			configuration = query.getSingleResult();
		} catch (NoResultException nre) {
			LOGGER.error(nre.getMessage(), nre);
		} catch (NonUniqueResultException nure) {
			LOGGER.error(nure.getMessage(), nure);
		}
		return configuration;
	}
}
{'fraction_non_alphanumeric': 0.10139301210321991, 'fraction_numerical': 0.0009134505594884677, 'mean_word_length': 5.0, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5329704', 'n_tokens_mistral': 1336, 'n_tokens_neox': 1299, 'n_words': 296}