1 package org.tigris.scarab.om; 2 3 import java.math.BigDecimal ; 4 import java.sql.Connection ; 5 import java.sql.SQLException ; 6 import java.util.ArrayList ; 7 import java.util.Date ; 8 import java.util.Iterator ; 9 import java.util.LinkedList ; 10 import java.util.List ; 11 12 import org.apache.torque.NoRowsException; 13 import org.apache.torque.TooManyRowsException; 14 import org.apache.torque.Torque; 15 import org.apache.torque.TorqueException; 16 import org.apache.torque.map.MapBuilder; 17 import org.apache.torque.map.TableMap; 18 import org.apache.torque.om.DateKey; 19 import org.apache.torque.om.NumberKey; 20 import org.apache.torque.om.StringKey; 21 import org.apache.torque.om.ObjectKey; 22 import org.apache.torque.om.SimpleKey; 23 import org.apache.torque.util.BasePeer; 24 import org.apache.torque.util.Criteria; 25 26 import com.workingdogs.village.DataSetException; 27 import com.workingdogs.village.QueryDataSet; 28 import com.workingdogs.village.Record; 29 30 import org.tigris.scarab.om.map.*; 32 33 34 36 public abstract class BaseScarabUserImplPeer 37 extends org.apache.fulcrum.security.impl.db.entity.TurbineUserPeer 38 { 39 40 41 public static final int numColumns = 1; 42 43 44 protected static final String CLASSNAME_DEFAULT = 45 "org.tigris.scarab.om.ScarabUserImpl"; 46 47 48 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 49 50 56 private static Class initClass(String className) 57 { 58 Class c = null; 59 try 60 { 61 c = Class.forName(className); 62 } 63 catch (Throwable t) 64 { 65 log.error("A FATAL ERROR has occurred which should not " 66 + "have happened under any circumstance. Please notify " 67 + "the Torque developers <torque-dev@db.apache.org> " 68 + "and give as many details as possible (including the error " 69 + "stack trace).", t); 70 71 if (t instanceof Error ) 73 { 74 throw (Error ) t.fillInStackTrace(); 75 } 76 } 77 return c; 78 } 79 80 81 82 90 public static Class getOMClass() 91 throws TorqueException 92 { 93 return CLASS_DEFAULT; 94 } 95 96 97 98 107 public static ScarabUserImpl retrieveScarabUserImplByPK(Integer pk) 108 throws TorqueException, NoRowsException, TooManyRowsException 109 { 110 return retrieveScarabUserImplByPK(SimpleKey.keyFor(pk)); 111 } 112 113 123 public static ScarabUserImpl retrieveScarabUserImplByPK(Integer pk, Connection con) 124 throws TorqueException, NoRowsException, TooManyRowsException 125 { 126 return retrieveScarabUserImplByPK(SimpleKey.keyFor(pk), con); 127 } 128 129 138 public static ScarabUserImpl retrieveScarabUserImplByPK(ObjectKey pk) 139 throws TorqueException, NoRowsException, TooManyRowsException 140 { 141 Connection db = null; 142 ScarabUserImpl retVal = null; 143 try 144 { 145 db = Torque.getConnection(DATABASE_NAME); 146 retVal = retrieveScarabUserImplByPK(pk, db); 147 } 148 finally 149 { 150 Torque.closeConnection(db); 151 } 152 return(retVal); 153 } 154 155 165 public static ScarabUserImpl retrieveScarabUserImplByPK(ObjectKey pk, Connection con) 166 throws TorqueException, NoRowsException, TooManyRowsException 167 { 168 Criteria criteria = buildCriteria(pk); 169 List v = doSelect(criteria, con); 170 if (v.size() == 0) 171 { 172 throw new NoRowsException("Failed to select a row."); 173 } 174 else if (v.size() > 1) 175 { 176 throw new TooManyRowsException("Failed to select only one row."); 177 } 178 else 179 { 180 return (ScarabUserImpl)v.get(0); 181 } 182 } 183 184 191 public static List retrieveScarabUserImplByPKs(List pks) 192 throws TorqueException 193 { 194 Connection db = null; 195 List retVal = null; 196 try 197 { 198 db = Torque.getConnection(DATABASE_NAME); 199 retVal = retrieveScarabUserImplByPKs(pks, db); 200 } 201 finally 202 { 203 Torque.closeConnection(db); 204 } 205 return(retVal); 206 } 207 208 216 public static List retrieveScarabUserImplByPKs( List pks, Connection dbcon ) 217 throws TorqueException 218 { 219 List objs = null; 220 if (pks == null || pks.size() == 0) 221 { 222 objs = new LinkedList (); 223 } 224 else 225 { 226 Criteria criteria = new Criteria(); 227 criteria.addIn( USER_ID, pks ); 228 objs = doSelect(criteria, dbcon); 229 } 230 return objs; 231 } 232 233 234 235 236 237 238 239 240 241 242 243 private static void setDbName(Criteria crit) 244 { 245 if (crit.getDbName() == Torque.getDefaultDB()) 249 { 250 crit.setDbName(DATABASE_NAME); 251 } 252 } 253 } 254 | Popular Tags |