1 package org.hibernate.test.legacy; 3 4 import java.io.Serializable ; 5 import java.sql.SQLException ; 6 import java.util.Calendar ; 7 import java.util.Date ; 8 import java.util.HashMap ; 9 import java.util.HashSet ; 10 import java.util.Iterator ; 11 import java.util.Map ; 12 import java.util.Set ; 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 { 20 private String fum; 21 private FumCompositeID id; 22 private Fum fo; 23 private Qux[] quxArray; 24 private Set friends; 25 private Calendar lastUpdated; 26 private String 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 , HibernateException { 33 this.id = id; 34 friends = new HashSet (); 35 FumCompositeID fid = new FumCompositeID(); 36 fid.setDate( new Date () ); 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 getFum() { 45 return fum; 46 } 47 public void setFum(String 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 getFriends() { 72 return friends; 73 } 74 75 public void setFriends(Set 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 iter = friends.iterator(); 84 while ( iter.hasNext() ) { 85 s.delete( iter.next() ); 86 } 87 } 88 catch (Exception e) { 89 throw new CallbackException(e); 90 } 91 return false; 92 } 93 94 95 public void onLoad(Session s, Serializable id) { 96 } 97 98 99 public boolean onSave(Session s) throws CallbackException { 100 if (friends==null) return false; 101 try { 102 Iterator iter = friends.iterator(); 103 while ( iter.hasNext() ) { 104 s.save( iter.next() ); 105 } 106 } 107 catch (Exception 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 getLastUpdated() { 119 return lastUpdated; 120 } 121 122 public void setLastUpdated(Calendar calendar) { 123 lastUpdated = calendar; 124 } 125 126 public String getTString() { 127 return tString; 128 } 129 130 public void setTString(String 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 { 143 private Map fummap = new HashMap (); 144 private Map stringmap = new HashMap (); 145 private int count; 146 public Map getFummap() { 147 return fummap; 148 } 149 150 public void setFummap(Map 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 getStringmap() { 163 return stringmap; 164 } 165 166 public void setStringmap(Map 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 |