KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > test > legacy > Qux


1 //$Id: Qux.java,v 1.1 2004/09/26 05:18:25 oneovthafew Exp $
2
package org.hibernate.test.legacy;
3
4 import java.io.Serializable JavaDoc;
5 import java.sql.SQLException JavaDoc;
6 import java.util.List JavaDoc;
7 import java.util.Set JavaDoc;
8
9 import org.hibernate.CallbackException;
10 import org.hibernate.HibernateException;
11 import org.hibernate.Session;
12 import org.hibernate.classic.Lifecycle;
13
14 public class Qux implements Lifecycle {
15
16     boolean created;
17     boolean deleted;
18     boolean loaded;
19     boolean stored;
20     private Long JavaDoc key;
21     private String JavaDoc stuff;
22     private Set JavaDoc fums;
23     private List JavaDoc moreFums;
24     private Qux child;
25     private Session session;
26     private Long JavaDoc childKey;
27     private Holder holder;
28
29     private FooProxy foo;
30
31     public Qux() { }
32
33     public Qux(String JavaDoc s) {
34         stuff=s;
35     }
36
37     public boolean onSave(Session session) throws CallbackException {
38         created=true;
39         try {
40             foo = new Foo();
41             session.save(foo);
42         }
43         catch (Exception JavaDoc e) {
44             throw new CallbackException(e);
45         }
46         foo.setString("child of a qux");
47         return NO_VETO;
48     }
49
50     public boolean onDelete(Session session) throws CallbackException {
51         deleted=true;
52         try {
53             session.delete(foo);
54         }
55         catch (Exception JavaDoc e) {
56             throw new CallbackException(e);
57         }
58         //if (child!=null) session.delete(child);
59
return NO_VETO;
60     }
61
62     public void onLoad(Session session, Serializable JavaDoc id) {
63         loaded=true;
64         this.session=session;
65     }
66
67     public void store() {
68     }
69
70     public FooProxy getFoo() {
71         return foo;
72     }
73     public void setFoo(FooProxy foo) {
74         this.foo = foo;
75     }
76
77     public boolean getCreated() {
78         return created;
79     }
80     private void setCreated(boolean created) {
81         this.created = created;
82     }
83
84     public boolean getDeleted() {
85         return deleted;
86     }
87
88     private void setDeleted(boolean deleted) {
89         this.deleted = deleted;
90     }
91
92     public boolean getLoaded() {
93         return loaded;
94     }
95     private void setLoaded(boolean loaded) {
96         this.loaded = loaded;
97     }
98
99     public boolean getStored() {
100         return stored;
101     }
102     private void setStored(boolean stored) {
103         this.stored = stored;
104     }
105
106     public Long JavaDoc getKey() {
107         return key;
108     }
109
110     private void setKey(long key) {
111         this.key = new Long JavaDoc(key);
112     }
113
114     public void setTheKey(long key) {
115         this.key = new Long JavaDoc(key);
116     }
117
118     public String JavaDoc getStuff() {
119         return stuff;
120     }
121     public void setStuff(String JavaDoc stuff) {
122         this.stuff = stuff;
123     }
124
125     public Set JavaDoc getFums() {
126         return fums;
127     }
128
129     public void setFums(Set JavaDoc fums) {
130         this.fums = fums;
131     }
132
133     public List JavaDoc getMoreFums() {
134         return moreFums;
135     }
136     public void setMoreFums(List JavaDoc moreFums) {
137         this.moreFums = moreFums;
138     }
139
140     public Qux getChild() throws HibernateException, SQLException JavaDoc {
141         stored=true;
142         this.childKey = child==null ? null : child.getKey();
143         if (childKey!=null && child==null) child = (Qux) session.load(Qux.class, childKey);
144         return child;
145     }
146
147     public void setChild(Qux child) {
148         this.child = child;
149     }
150
151     private Long JavaDoc getChildKey() {
152         return childKey;
153     }
154
155     private void setChildKey(Long JavaDoc childKey) {
156         this.childKey = childKey;
157     }
158
159     public boolean onUpdate(Session s) throws CallbackException {
160         return NO_VETO;
161     }
162
163     protected void finalize() { }
164
165     public Holder getHolder() {
166         return holder;
167     }
168
169     public void setHolder(Holder holder) {
170         this.holder = holder;
171     }
172
173 }
174
175
176
177
178
179
180
181
Popular Tags