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.OneToOne;
31 import javax.persistence.Table;
32 import javax.persistence.Temporal;
33 import javax.persistence.TemporalType;
34 import org.mxchange.addressbook.model.addressbook.status.AddressbokStatus;
35 import org.mxchange.jusercore.model.user.LoginUser;
36 import org.mxchange.jusercore.model.user.User;
39 * A POJO for user addressbooks
41 * @author Roland Haeder
43 @Entity (name = "addressbooks")
44 @Table (name = "addressbooks")
45 public class UserAddressbook implements Addressbook, Comparable<Addressbook> {
50 private static final long serialVersionUID = 176_573_148_678_169L;
56 @GeneratedValue (strategy = GenerationType.IDENTITY)
57 @Column (name = "addressbook_id", length = 20, nullable = false, updatable = false)
58 private Long addressbookId;
61 * Connection to "users" table
63 @JoinColumn (name = "addressbook_user_id", nullable = false)
64 @OneToOne (targetEntity = LoginUser.class, optional = false, cascade = CascadeType.ALL)
65 private User addressbookUser;
68 * When this address book has been created
70 @Basic (optional = false)
71 @Temporal (TemporalType.TIMESTAMP)
72 @Column (name = "addressbook_created", nullable = false, updatable = false)
73 private Calendar addressbookCreated;
78 @Basic (optional = false)
79 @Enumerated (EnumType.STRING)
80 @Column (name = "addressbook_status", nullable = false, length = 10)
81 private AddressbokStatus addressbookStatus;
84 * Name for this address book
86 @Basic (optional = false)
87 @Column (name = "addressbook_name", length = 50, nullable = false)
88 private String addressbookName;
91 public int compareTo (final Addressbook addressbook) {
92 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
96 public Long getAddressbookId () {
97 return this.addressbookId;
101 public void setAddressbookId (final Long addressbookId) {
102 this.addressbookId = addressbookId;