2 * Copyright (C) 2015 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.addressbook.model.addressbook;
19 import java.util.Calendar;
20 import javax.persistence.Basic;
21 import javax.persistence.CascadeType;
22 import javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.EnumType;
25 import javax.persistence.Enumerated;
26 import javax.persistence.GeneratedValue;
27 import javax.persistence.GenerationType;
28 import javax.persistence.Id;
29 import javax.persistence.JoinColumn;
30 import javax.persistence.NamedQueries;
31 import javax.persistence.NamedQuery;
32 import javax.persistence.OneToOne;
33 import javax.persistence.Table;
34 import javax.persistence.Temporal;
35 import javax.persistence.TemporalType;
36 import org.mxchange.addressbook.model.addressbook.status.AddressbokStatus;
37 import org.mxchange.jusercore.model.user.LoginUser;
38 import org.mxchange.jusercore.model.user.User;
41 * A POJO for user addressbooks
43 * @author Roland Haeder
45 @Entity (name = "addressbooks")
46 @Table (name = "addressbooks")
49 @NamedQuery (name = "AllUsersAddressbooks", query = "SELECT a FROM addressbooks AS a WHERE a.addressbookUser = :param ORDER BY a.addressbookId ASC")
52 public class UserAddressbook implements Addressbook, Comparable<Addressbook> {
57 private static final long serialVersionUID = 176_573_148_678_169L;
63 @GeneratedValue (strategy = GenerationType.IDENTITY)
64 @Column (name = "addressbook_id", length = 20, nullable = false, updatable = false)
65 private Long addressbookId;
68 * Connection to "users" table
70 @JoinColumn (name = "addressbook_user_id", nullable = false)
71 @OneToOne (targetEntity = LoginUser.class, optional = false, cascade = CascadeType.ALL)
72 private User addressbookUser;
75 * When this address book has been created
77 @Basic (optional = false)
78 @Temporal (TemporalType.TIMESTAMP)
79 @Column (name = "addressbook_created", nullable = false, updatable = false)
80 private Calendar addressbookCreated;
85 @Basic (optional = false)
86 @Enumerated (EnumType.STRING)
87 @Column (name = "addressbook_status", nullable = false, length = 10)
88 private AddressbokStatus addressbookStatus;
91 * Name for this address book
93 @Basic (optional = false)
94 @Column (name = "addressbook_name", length = 50, nullable = false)
95 private String addressbookName;
98 public int compareTo (final Addressbook addressbook) {
99 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
103 public Calendar getAddressbookCreated () {
104 return this.addressbookCreated;
108 public void setAddressbookCreated (final Calendar addressbookCreated) {
109 this.addressbookCreated = addressbookCreated;
113 public Long getAddressbookId () {
114 return this.addressbookId;
118 public void setAddressbookId (final Long addressbookId) {
119 this.addressbookId = addressbookId;
123 public String getAddressbookName () {
124 return this.addressbookName;
128 public void setAddressbookName (final String addressbookName) {
129 this.addressbookName = addressbookName;
133 public AddressbokStatus getAddressbookStatus () {
134 return this.addressbookStatus;
138 public void setAddressbookStatus (final AddressbokStatus addressbookStatus) {
139 this.addressbookStatus = addressbookStatus;
143 public User getAddressbookUser () {
144 return this.addressbookUser;
148 public void setAddressbookUser (final User addressbookUser) {
149 this.addressbookUser = addressbookUser;