/** * The returned List will contain objects of the default type or objects that inherit from the * default. * * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a * TorqueException. */ public static List<User> populateObjects(List<Record> records) throws TorqueException { List<User> results = new ArrayList<User>(records.size()); // populate the object(s) for (int i = 0; i < records.size(); i++) { Record row = records.get(i); results.add(UserPeer.row2Object(row, 1, UserPeer.getOMClass())); } return results; }
/** * selects a collection of System_Log objects pre-filled with their User objects. * * <p>This method is protected by default in order to keep the public api reasonable. You can * provide public methods for those you actually need in System_LogPeer. * * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a * TorqueException. */ protected static List doSelectJoinUser(Criteria c) throws TorqueException { // Set the correct dbName if it has not been overridden // c.getDbName will return the same object if not set to // another value so == check is okay and faster if (c.getDbName() == Torque.getDefaultDB()) { c.setDbName(DATABASE_NAME); } System_LogPeer.addSelectColumns(c); int offset = numColumns + 1; UserPeer.addSelectColumns(c); c.addJoin(System_LogPeer.USER_ID, UserPeer.USER_ID); List rows = BasePeer.doSelect(c); List results = new ArrayList(); for (int i = 0; i < rows.size(); i++) { Record row = (Record) rows.get(i); Class omClass = System_LogPeer.getOMClass(); System_Log obj1 = (System_Log) System_LogPeer.row2Object(row, 1, omClass); omClass = UserPeer.getOMClass(); User obj2 = (User) UserPeer.row2Object(row, offset, omClass); boolean newObject = true; for (int j = 0; j < results.size(); j++) { System_Log temp_obj1 = (System_Log) results.get(j); User temp_obj2 = (User) temp_obj1.getUser(); if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) { newObject = false; temp_obj2.addSystem_Log(obj1); break; } } if (newObject) { obj2.initSystem_Logs(); obj2.addSystem_Log(obj1); } results.add(obj1); } return results; }
/** * Create a new object of type cls from a resultset row starting from a specified offset. This is * done so that you can select other rows than just those needed for this object. You may for * example want to create two objects from the same row. * * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a * TorqueException. */ public static User row2Object(Record row, int offset, Class cls) throws TorqueException { try { User obj = (User) cls.newInstance(); UserPeer.populateObject(row, offset, obj); obj.setModified(false); obj.setNew(false); return obj; } catch (InstantiationException e) { throw new TorqueException(e); } catch (IllegalAccessException e) { throw new TorqueException(e); } }
/** * Method to do deletes. * * @param criteria object containing data that is used DELETE from database. * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a * TorqueException. */ public static void doDelete(Criteria criteria) throws TorqueException { UserPeer.doDelete(criteria, (Connection) null); }