de.lava.marvin.whaosleaguepersistence.dao.impl.MatchDaoImpl.java Source code

Java tutorial

Introduction

Here is the source code for de.lava.marvin.whaosleaguepersistence.dao.impl.MatchDaoImpl.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package de.lava.marvin.whaosleaguepersistence.dao.impl;

import de.lava.marvin.whaosleaguebeans.Match;
import de.lava.marvin.whaosleaguepersistence.dao.MatchDao;
import java.util.List;
import javax.persistence.TypedQuery;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author mlava
 */
@Repository
@Transactional(propagation = Propagation.REQUIRED)
public class MatchDaoImpl extends BaseDaoImpl<Match> implements MatchDao {

    @Override
    public List<Match> getAllMatches() {
        TypedQuery<Match> query = entityManager.createNamedQuery("allMatches", Match.class);
        return query.getResultList();
    }

    @Override
    public List<Match> getAllRankedMatches() {
        TypedQuery<Match> query = entityManager.createNamedQuery("allRankedMatches", Match.class);
        return query.getResultList();
    }

    @Override
    public List<Match> getAllUnrankedMatches() {
        TypedQuery<Match> query = entityManager.createNamedQuery("allUnrankedMatches", Match.class);
        return query.getResultList();
    }

}