<commit_before>package be.markito.kubb.api.persistence;

import be.markito.kubb.api.persistence.filter.TeamFilter;
import be.markito.kubb.api.persistence.model.Team;
import be.markito.kubb.api.persistence.model.Team_;
import be.markito.kubb.api.persistence.util.QueryResultHelper;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Repository;
import org.springframework.util.Assert;

import javax.persistence.TypedQuery;
import javax.persistence.criteria.*;
import java.util.ArrayList;
import java.util.List;

/**
 * TODO add some javadoc here.
 *
 * @author MArKiTo
 */
@Repository("teamDao")
public class TeamDaoImpl extends AbstractBaseDao implements TeamDao {
    /**
     * {@inheritDoc}
     */
    @Override
    public List<Team> find(TeamFilter filter) {
        Assert.notNull(filter, "PRE: Filter should not be null");

        CriteriaBuilder cb = getEm().getCriteriaBuilder();
        CriteriaQuery<Team> query = cb.createQuery(Team.class);
        Root<Team> from = query.from(Team.class);
        query.distinct(true);

        List<Predicate> predicates = new ArrayList<>();
        if (StringUtils.isNotBlank(filter.getName())) {
            predicates.add(cb.like(cb.upper(from.get(Team_.name)), "%" + StringUtils.upperCase(filter.getName()) + "%"));
        }
        query.where(cb.and(predicates.toArray(new Predicate[predicates.size()])));
        query.orderBy(cb.asc(from.get(Team_.id)));
        TypedQuery<Team> q = getEm().createQuery(query);
        return q.getResultList();
    }
    
    /**
     * {@inheritDoc}
     */
    public Team findById(Long id) {
        assertPrimaryKey(id);

        CriteriaBuilder cb = getEm().getCriteriaBuilder();
        CriteriaQuery<Team> query = cb.createQuery(Team.class);
        Root<Team> from = query.from(Team.class);
        query.distinct(true);<commit_msg>Sorting updated.<commit_after>package be.markito.kubb.api.persistence;

import be.markito.kubb.api.persistence.filter.TeamFilter;
import be.markito.kubb.api.persistence.model.Team;
import be.markito.kubb.api.persistence.model.Team_;
import be.markito.kubb.api.persistence.util.QueryResultHelper;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Repository;
import org.springframework.util.Assert;

import javax.persistence.TypedQuery;
import javax.persistence.criteria.*;
import java.util.ArrayList;
import java.util.List;

/**
 * TODO add some javadoc here.
 *
 * @author MArKiTo
 */
@Repository("teamDao")
public class TeamDaoImpl extends AbstractBaseDao implements TeamDao {
    /**
     * {@inheritDoc}
     */
    @Override
    public List<Team> find(TeamFilter filter) {
        Assert.notNull(filter, "PRE: Filter should not be null");

        CriteriaBuilder cb = getEm().getCriteriaBuilder();
        CriteriaQuery<Team> query = cb.createQuery(Team.class);
        Root<Team> from = query.from(Team.class);
        query.distinct(true);

        List<Predicate> predicates = new ArrayList<>();
        if (StringUtils.isNotBlank(filter.getName())) {
            predicates.add(cb.like(cb.upper(from.get(Team_.name)), "%" + StringUtils.upperCase(filter.getName()) + "%"));
        }
        query.where(cb.and(predicates.toArray(new Predicate[predicates.size()])));
        query.orderBy(cb.asc(from.get(Team_.name)));
        TypedQuery<Team> q = getEm().createQuery(query);
        return q.getResultList();
    }
    
    /**
     * {@inheritDoc}
     */
    public Team findById(Long id) {
        assertPrimaryKey(id);

        CriteriaBuilder cb = getEm().getCriteriaBuilder();
        CriteriaQuery<Team> query = cb.createQuery(Team.class);
        Root<Team> from = query.from(Team.class);
        query.distinct(true);
{'fraction_non_alphanumeric': 0.13849450843825342, 'fraction_numerical': 0.0, 'mean_word_length': 3.482593037214886, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '677223', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1146, 'n_words': 188}