package com.mkl.eu.service.service.persistence.board.impl;

import com.mkl.eu.service.service.persistence.board.ICounterDao;
import com.mkl.eu.service.service.persistence.impl.GenericDaoImpl;
import com.mkl.eu.service.service.persistence.oe.board.CounterEntity;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

/**
 * Implementation of the Counter DAO.
 *
 * @author MKL.
 */
@Repository
public class CounterDaoImpl extends GenericDaoImpl<CounterEntity, Long> implements ICounterDao {
    /**
     * Constructor.
     */
    public CounterDaoImpl() {
        super(CounterEntity.class);
    }

    /** {@inheritDoc} */
    @Override
    public CounterEntity getCounter(Long idCounter, Long idGame) {
        Criteria criteria = getSession().createCriteria(CounterEntity.class);

        criteria.add(Restrictions.eq("id", idCounter));
        criteria.add(Restrictions.eq("owner.game.id", idGame));

        return (CounterEntity) criteria.uniqueResult();
    }
}

@@ -259,84 +259,8 @@
 ty;%0A
-import org.hibernate.Criteria;%0Aimport org.hibernate.criterion.Restrictions;%0A
 impo
@@ -708,197 +708,311 @@
    C
-riteria cri
+ounterEntity coun
 ter
-ia
  = 
-getSession().createCriteria(CounterEntity.class);%0A%0A        criteria.add(Restrictions.eq(%22id%22, idCounter));%0A        criteria.add(Restrictions.eq(%22owner.game.id%22, idGame));
+load(idCounter);%0A%0A        if (idGame == null %7C%7C counter == null %7C%7C counter.getOwner() == null%0A                %7C%7C counter.getOwner().getGame() == null%0A                %7C%7C counter.getOwner().getGame().getId().longValue() != idGame.longValue()) %7B%0A            counter = null;%0A        %7D
 %0A%0A  
@@ -1028,47 +1028,15 @@
 urn 
-(C
+c
 ounter
-Entity) criteria.uniqueResult()
 ;%0A  

Fix bug