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

Java tutorial

Introduction

Here is the source code for de.lava.marvin.whaosleaguepersistence.dao.impl.LeagueDaoImpl.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.League;
import de.lava.marvin.whaosleaguepersistence.dao.LeagueDao;
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 LeagueDaoImpl extends BaseDaoImpl<League> implements LeagueDao {

    @Override
    public List<League> getAllLeagues() {
        TypedQuery<League> query = entityManager.createNamedQuery("allLeagues", League.class);
        return query.getResultList();
    }

    @Override
    public List<League> getAllRankedLeagues() {
        TypedQuery<League> query = entityManager.createNamedQuery("allRankedLeagues", League.class);
        return query.getResultList();
    }

    @Override
    public List<League> getAllUnrankedLeagues() {
        TypedQuery<League> query = entityManager.createNamedQuery("allUnrankedLeagues", League.class);
        return query.getResultList();
    }

}