KickJava   Java API By Example, From Geeks To Geeks.

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


1 //$Id: Fum.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.Calendar JavaDoc;
7 import java.util.Date JavaDoc;
8 import java.util.HashMap JavaDoc;
9 import java.util.HashSet JavaDoc;
10 import java.util.Iterator JavaDoc;
11 import java.util.Map JavaDoc;
12 import java.util.Set JavaDoc;
13
14 import org.hibernate.CallbackException;
15 import org.hibernate.HibernateException;
16 import org.hibernate.Session;
17 import org.hibernate.classic.Lifecycle;
18
19 public class Fum implements Lifecycle, Serializable JavaDoc {
20     private String JavaDoc fum;
21     private FumCompositeID id;
22     private Fum fo;
23     private Qux[] quxArray;
24     private Set JavaDoc friends;
25     private Calendar JavaDoc lastUpdated;
26     private String JavaDoc tString;
27     private short vid;
28     private short dupe;
29     private MapComponent mapComponent = new MapComponent();
30
31     public Fum() {}
32     public Fum(FumCompositeID id) throws SQLException JavaDoc, HibernateException {
33         this.id = id;
34         friends = new HashSet JavaDoc();
35         FumCompositeID fid = new FumCompositeID();
36         fid.setDate( new Date JavaDoc() );
37         fid.setShort( (short) ( id.short_ + 33 ) );
38         fid.setString( id.string_ + "dd" );
39         Fum f = new Fum();
40         f.id = fid;
41         f.fum="FRIEND";
42         friends.add(f);
43     }
44     public String JavaDoc getFum() {
45         return fum;
46     }
47     public void setFum(String JavaDoc fum) {
48         this.fum = fum;
49     }
50
51     public FumCompositeID getId() {
52         return id;
53     }
54     private void setId(FumCompositeID id) {
55         this.id = id;
56     }
57     public Fum getFo() {
58         return fo;
59     }
60     public void setFo(Fum fo) {
61         this.fo = fo;
62     }
63
64     public Qux[] getQuxArray() {
65         return quxArray;
66     }
67     public void setQuxArray(Qux[] quxArray) {
68         this.quxArray = quxArray;
69     }
70
71     public Set JavaDoc getFriends() {
72         return friends;
73     }
74
75     public void setFriends(Set JavaDoc friends) {
76         this.friends = friends;
77     }
78
79
80     public boolean onDelete(Session s) throws CallbackException {
81         if (friends==null) return false;
82         try {
83             Iterator JavaDoc iter = friends.iterator();
84             while ( iter.hasNext() ) {
85                 s.delete( iter.next() );
86             }
87         }
88         catch (Exception JavaDoc e) {
89             throw new CallbackException(e);
90         }
91         return false;
92     }
93
94
95     public void onLoad(Session s, Serializable JavaDoc id) {
96     }
97
98
99     public boolean onSave(Session s) throws CallbackException {
100         if (friends==null) return false;
101         try {
102             Iterator JavaDoc iter = friends.iterator();
103             while ( iter.hasNext() ) {
104                 s.save( iter.next() );
105             }
106         }
107         catch (Exception JavaDoc e) {
108             throw new CallbackException(e);
109         }
110         return false;
111     }
112
113
114     public boolean onUpdate(Session s) throws CallbackException {
115         return false;
116     }
117
118     public Calendar JavaDoc getLastUpdated() {
119         return lastUpdated;
120     }
121
122     public void setLastUpdated(Calendar JavaDoc calendar) {
123         lastUpdated = calendar;
124     }
125
126     public String JavaDoc getTString() {
127         return tString;
128     }
129
130     public void setTString(String JavaDoc string) {
131         tString = string;
132     }
133
134     public short getDupe() {
135         return dupe;
136     }
137
138     public void setDupe(short s) {
139         dupe = s;
140     }
141
142     public static final class MapComponent implements Serializable JavaDoc {
143         private Map JavaDoc fummap = new HashMap JavaDoc();
144         private Map JavaDoc stringmap = new HashMap JavaDoc();
145         private int count;
146         public Map JavaDoc getFummap() {
147             return fummap;
148         }
149
150         public void setFummap(Map JavaDoc mapcomponent) {
151             this.fummap = mapcomponent;
152         }
153
154         public int getCount() {
155             return count;
156         }
157
158         public void setCount(int count) {
159             this.count = count;
160         }
161
162         public Map JavaDoc getStringmap() {
163             return stringmap;
164         }
165
166         public void setStringmap(Map JavaDoc stringmap) {
167             this.stringmap = stringmap;
168         }
169
170     }
171
172     public MapComponent getMapComponent() {
173         return mapComponent;
174     }
175
176     public void setMapComponent(MapComponent mapComponent) {
177         this.mapComponent = mapComponent;
178     }
179
180 }
181
182
183
184
185
186
187
188
Popular Tags