/* License see bottom */
package jtrackbase.db;
import java.util.Collection;
import javax.persistence.EntityManager;
import javax.persistence.Query;
public class ArtistFacade extends AbstractFacade {
public static Collection<Artist> findAll() {
EntityManager em=DBController.getEntityManager();
// this could be done in a more specific way,
// e.g. with ExpressionBuilder from TopLink but
// by using such a special technique we'd loose
// portability
// --Onkobu Tanaake, Feb.2009
Query query = em.createQuery("SELECT a FROM Artist a");
return castToList(query.getResultList());
}
public static Collection<Artist> findByName(String n) {
EntityManager em=DBController.getEntityManager();
Query queryArtist = em.createNativeQuery(
"Select * from Artist where name = #aName", Artist.class
);
queryArtist.setParameter("aName", n);
return castToList(queryArtist.getResultList());
}
}
/*
Copyright (C) 2008 Onkobu Tanaake
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program (gplv3.txt).
*/