2 * Copyright (c) 2018. Developed by Hedgecode.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.hedgecode.chess.service.jpa;
19 import java.util.Date;
20 import java.util.List;
22 import javax.persistence.Query;
24 import org.hedgecode.chess.domain.Author;
25 import org.hedgecode.chess.service.AuthorService;
30 * @author Dmitry Samoshin aka gotty
32 public class JpaAuthorService extends JpaDomainService<Author> implements AuthorService {
38 public List<Author> findAll() {
39 return getEntityManager().createNamedQuery(
48 public Author findById(Long id) {
49 Query query = getEntityManager().createNamedQuery(
52 query.setParameter(Author.ID_PARAMETER, id);
53 return (Author) query.getSingleResult();
60 public List<Author> findByName(String name) {
61 Query query = getEntityManager().createNamedQuery(
64 query.setParameter(Author.NAME_PARAMETER, name);
65 return query.getResultList();
72 public List<Author> findByBirthDate(Date birthdate) {
73 Query query = getEntityManager().createNamedQuery(
74 Author.FIND_BY_BIRTHDATE
76 query.setParameter(Author.BIRTHDATE_PARAMETER, birthdate);
77 return query.getResultList();