01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.openjpa.persistence.annotations.common.apps.annotApp.annotype;
20:
21: import javax.persistence.*;
22:
23: @Entity
24: @Inheritance(strategy=InheritanceType.JOINED)
25: @EntityListeners({NameValidator.class,LongNameValidator.class})
26: public class Employee implements NamedEntity {
27: @Id
28: private int id;
29:
30: @Basic
31: protected String name;
32:
33: @GeneratedValue(strategy=GenerationType.AUTO)
34: protected int lifecheck;
35:
36: @Transient
37: protected long syncTime;
38:
39: public Employee() {
40: }
41:
42: public Employee(int id, String name) {
43: this .id = id;
44: this .name = name;
45: }
46:
47: public String getName() {
48: return name;
49: }
50:
51: public void setName(String name) {
52: this .name = name;
53: }
54:
55: public void setId(int id) {
56: this .id = id;
57: }
58:
59: public int getId() {
60: return id;
61: }
62:
63: @PostPersist
64: private void resetSyncTime() {
65: System.out.println("resetSyncTime is running on " + this
66: + "GEN #: " + lifecheck);
67: syncTime = System.currentTimeMillis();
68:
69: CallbackStorage store = CallbackStorage.getInstance();
70: store.getClist().add("employeepop");
71: store.getClist().add("gen#" + lifecheck);
72: }
73:
74: @PostLoad
75: public void pload() {
76: CallbackStorage store = CallbackStorage.getInstance();
77: store.getClist().add("employeepol");
78: }
79:
80: @PostUpdate
81: public void pupdate() {
82: CallbackStorage store = CallbackStorage.getInstance();
83: store.getClist().add("employeepou");
84: }
85:
86: public String toString() {
87: return "Name: " + name + " of " + this .getClass().getName()
88: + " Id: " + id + " Synctime: " + syncTime;
89: }
90:
91: public int getCheck() {
92: return this .lifecheck;
93: }
94:
95: public void setCheck(int check) {
96: this.lifecheck = check;
97: }
98: }
|