1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002, 2014 Oracle and/or its affiliates.  All rights reserved.
5  *
6  */
7 
8 package persist.sqlapp;
9 
10 import com.sleepycat.persist.model.Entity;
11 import com.sleepycat.persist.model.PrimaryKey;
12 import com.sleepycat.persist.model.SecondaryKey;
13 import static com.sleepycat.persist.model.Relationship.ONE_TO_ONE;
14 
15 /**
16  * The Department entity class.
17  *
18  * @author chao
19  */
20 @Entity
21 class Department {
22 
23     @PrimaryKey
24     int departmentId;
25 
26     @SecondaryKey(relate = ONE_TO_ONE)
27     String departmentName;
28 
29     String location;
30 
Department(int departmentId, String departmentName, String location)31     public Department(int departmentId,
32                       String departmentName,
33                       String location) {
34 
35         this.departmentId = departmentId;
36         this.departmentName = departmentName;
37         this.location = location;
38     }
39 
40         @SuppressWarnings("unused")
Department()41     private Department() {} // Needed for deserialization.
42 
getDepartmentId()43     public int getDepartmentId() {
44         return departmentId;
45     }
46 
getDepartmentName()47     public String getDepartmentName() {
48         return departmentName;
49     }
50 
getLocation()51     public String getLocation() {
52         return location;
53     }
54 
55     @Override
toString()56     public String toString() {
57         return this.departmentId + ", " +
58                this.departmentName + ", " +
59                this.location;
60     }
61 }
62