package com.peetz.comics.dal;

import java.util.List;

import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import com.peetz.comics.entity.ArtistEntity;

@Stateless(name = "ArtistDao")
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class ArtistImpl implements ArtistDao {

	@PersistenceContext(unitName = "kontor")
	private EntityManager em;

	@Override
	public ArtistEntity getById(Long id) {
		Query q = em.createNamedQuery("");
		q.setParameter("id", id);
		ArtistEntity entity = (ArtistEntity)q.getSingleResult();
		return entity;
	}

	@Override
	public List<ArtistEntity> findByIds(List<Long> ids) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ArtistEntity store(ArtistEntity entity) {
		em.persist(entity);
		return entity;
	}

	@Override
	public void delete(ArtistEntity entity) {
		em.remove(entity);
	}
}