/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pa165.dao;

import cz.muni.fi.pa165.entity.BookCollection;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author xkubist
 */
@Repository
public class BookCollectionDaoImpl implements BookCollectionDao {
    @PersistenceContext
    private EntityManager em;

    public void create (BookCollection b){
        em.persist(b);
    }
    public void delete(BookCollection b){
        em.remove(b);
    }
    public void update(BookCollection b){
        em.merge(b);
    }
    public List<BookCollection> findAll(){
        return em.createQuery("select b from BookCollection b", BookCollection.class)
				.getResultList();
    }
    public BookCollection findByName(String name){
            return em.find(BookCollection.class, name);
    }
    public BookCollection findById(Long id){
            return em.find(BookCollection.class, id);
    }
}

@@ -932,32 +932,37 @@
    %7D%0A    public 
+List%3C
 BookCollection f
@@ -955,24 +955,25 @@
 okCollection
+%3E
  findByName(
@@ -1012,39 +1012,125 @@
  em.
-find(BookCollection.class, name
+createQuery(%22from BookCollection where name = :name%22, BookCollection.class).setParameter(%22name%22, name).getResultList(
 );%0A 

fix bug in BookCollectionDaoImpl class