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.domain;
19 import java.util.Date;
21 import javax.persistence.Column;
22 import javax.persistence.Entity;
23 import javax.persistence.GeneratedValue;
24 import javax.persistence.GenerationType;
25 import javax.persistence.Id;
26 import javax.persistence.NamedQueries;
27 import javax.persistence.NamedQuery;
28 import javax.persistence.Table;
29 import javax.persistence.Temporal;
30 import javax.persistence.TemporalType;
35 * @author Dmitry Samoshin aka gotty
43 name = Author.FIND_ALL,
44 query = "select a from Author a"
47 name = Author.FIND_BY_ID,
48 query = "select a from Author a where a.id = :id"
51 name = Author.FIND_BY_NAME,
52 query = "select a from Author a where a.name like :name"
55 name = Author.FIND_BY_BIRTHDATE,
56 query = "select a from Author a where a.birthdate = :birthdate"
59 public class Author extends DomainObject<Author> {
61 public static final String FIND_ALL = "Author.findAll";
62 public static final String FIND_BY_ID = "Author.findById";
63 public static final String FIND_BY_NAME = "Author.findByName";
64 public static final String FIND_BY_BIRTHDATE = "Author.findByBirthDate";
66 public static final String NAME_PARAMETER = "name";
67 public static final String BIRTHDATE_PARAMETER = "birthdate";
74 strategy = GenerationType.AUTO
79 name = "f_name", nullable = false
87 value = TemporalType.DATE
89 private Date birthdate;
95 value = TemporalType.DATE
97 private Date deathdate;
102 private String biography;
107 private String comment;
109 public <TargetType> TargetType assemble(TargetType target, AuthorAdapter<TargetType> adapter) {
110 adapter.setId(target, id);
111 adapter.setName(target, name);
112 adapter.setBirthdate(target, birthdate);
113 adapter.setDeathdate(target, deathdate);
114 adapter.setBiography(target, biography);
115 adapter.setComment(target, comment);
121 public Long getId() {