1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 2002,2008 Oracle. All rights reserved.
*
* $Id: Employee.java,v 1.1 2008/05/09 03:16:01 chao Exp $
*/
package persist.sqlapp;
import com.sleepycat.persist.model.Entity;
import com.sleepycat.persist.model.PrimaryKey;
import com.sleepycat.persist.model.SecondaryKey;
import static com.sleepycat.persist.model.DeleteAction.NULLIFY;
import static com.sleepycat.persist.model.Relationship.MANY_TO_ONE;
/**
* The Employee entity class.
*
* @author chao
*/
@Entity
class Employee {
@PrimaryKey
int employeeId;
@SecondaryKey(relate = MANY_TO_ONE)
String employeeName;
@SecondaryKey(relate = MANY_TO_ONE)
float salary;
@SecondaryKey(relate = MANY_TO_ONE, relatedEntity=Employee.class,
onRelatedEntityDelete=NULLIFY)
Integer managerId; // Use "Integer" to allow null values.
@SecondaryKey(relate = MANY_TO_ONE, relatedEntity=Department.class,
onRelatedEntityDelete=NULLIFY)
int departmentId;
String address;
public Employee(int employeeId,
String employeeName,
float salary,
Integer managerId,
int departmentId,
String address) {
this.employeeId = employeeId;
this.employeeName = employeeName;
this.salary = salary;
this.managerId = managerId;
this.departmentId = departmentId;
this.address = address;
}
private Employee() {} // For bindings
public String getAddress() {
return address;
}
public int getDepartmentId() {
return departmentId;
}
public int getEmployeeId() {
return employeeId;
}
public String getEmployeeName() {
return employeeName;
}
public Integer getManagerId() {
return managerId;
}
public float getSalary() {
return salary;
}
@Override
public String toString() {
return this.employeeId + ", " +
this.employeeName + ", " +
this.salary + ", " +
this.managerId + ", " +
this.departmentId + ", " +
this.address;
}
}
|