001package org.apache.fulcrum.security.torque.om;
002
003import java.sql.Connection;
004import java.util.ArrayList;
005import java.util.Collection;
006import java.util.List;
007import java.util.Map;
008import java.util.Objects;
009import java.util.stream.Collectors;
010
011import org.apache.torque.NoRowsException;
012import org.apache.torque.TooManyRowsException;
013import org.apache.torque.TorqueException;
014import org.apache.torque.criteria.Criteria;
015import org.apache.torque.criteria.Criterion;
016import org.apache.torque.om.mapper.RecordMapper;
017import org.apache.torque.om.mapper.CompositeMapper;
018import org.apache.torque.om.ObjectKey;
019import org.apache.torque.om.SimpleKey;
020import org.apache.torque.map.TableMap;
021import org.apache.torque.util.TorqueConnection;
022import org.apache.torque.util.Transaction;
023import org.apache.torque.util.ColumnValues;
024import org.apache.torque.util.JdbcTypedValue;
025
026
027
028/**
029 * The skeleton for this class was autogenerated by Torque on:
030 *
031 * [Thu Nov 04 13:34:23 CET 2021]
032 *
033 * You should not use this class directly.  It should not even be
034 * extended; all references should be to TurbineUserGroupRolePeer
035 */
036
037@SuppressWarnings("unused")
038public abstract class BaseTurbineUserGroupRolePeerImpl
039    extends org.apache.torque.util.AbstractPeerImpl<TurbineUserGroupRole>
040{
041    /** Serial version */
042    private static final long serialVersionUID = 1636029263441L;
043
044
045
046    /**
047     * Constructor.
048     * The recordMapper, tableMap and databaseName fields are correctly
049     * initialized.
050     */
051    public BaseTurbineUserGroupRolePeerImpl()
052    {
053        this(new TurbineUserGroupRoleRecordMapper(),
054            TurbineUserGroupRolePeer.TABLE,
055            TurbineUserGroupRolePeer.DATABASE_NAME);
056    }
057
058    /**
059     * Constructor providing the objects to be injected as parameters.
060     *
061     * @param recordMapper a record mapper to map JDBC result sets to objects
062     * @param tableMap the default table map
063     * @param databaseName the name of the database
064     */
065    public BaseTurbineUserGroupRolePeerImpl(
066            RecordMapper<TurbineUserGroupRole> recordMapper, 
067            TableMap tableMap,
068            String databaseName)
069    {
070        super(recordMapper, tableMap, databaseName);
071    }
072
073
074    /**
075     * Returns a new instance of the Data object class
076     */
077    public TurbineUserGroupRole getDbObjectInstance()
078    {
079        return new TurbineUserGroupRole();
080    }
081
082
083    /**
084     * Method to do updates.  This method is to be used during a transaction,
085     * otherwise use the doUpdate(Criteria) method.
086     *
087     * @param columnValues the values to update plus the primary key
088     *        identifying the row to update.
089     * @param con the connection to use, not null.
090     *
091     * @return the number of affected rows.
092     *
093     * @throws TorqueException Any exceptions caught during processing will be
094     *         rethrown wrapped into a TorqueException.
095     */
096    public int doUpdate(ColumnValues columnValues, Connection con)
097        throws TorqueException
098    {
099        Criteria selectCriteria = new Criteria(getDatabaseName());
100        correctBooleans(columnValues);
101
102        {
103            JdbcTypedValue pkValue
104                = columnValues.remove(TurbineUserGroupRolePeer.USER_ID);
105            if (pkValue == null)
106            {
107                throw new TorqueException(
108                        "The value for the primary key column "
109                        + "TurbineUserGroupRolePeer.USER_ID"
110                        + " must be set");
111            }
112            if (pkValue.getSqlExpression() == null)
113            {
114                selectCriteria.where(
115                        TurbineUserGroupRolePeer.USER_ID,
116                        pkValue.getValue());
117            }
118            else
119            {
120                selectCriteria.where(
121                        TurbineUserGroupRolePeer.USER_ID,
122                        pkValue.getSqlExpression());
123            }
124        }
125        {
126            JdbcTypedValue pkValue
127                = columnValues.remove(TurbineUserGroupRolePeer.GROUP_ID);
128            if (pkValue == null)
129            {
130                throw new TorqueException(
131                        "The value for the primary key column "
132                        + "TurbineUserGroupRolePeer.GROUP_ID"
133                        + " must be set");
134            }
135            if (pkValue.getSqlExpression() == null)
136            {
137                selectCriteria.where(
138                        TurbineUserGroupRolePeer.GROUP_ID,
139                        pkValue.getValue());
140            }
141            else
142            {
143                selectCriteria.where(
144                        TurbineUserGroupRolePeer.GROUP_ID,
145                        pkValue.getSqlExpression());
146            }
147        }
148        {
149            JdbcTypedValue pkValue
150                = columnValues.remove(TurbineUserGroupRolePeer.ROLE_ID);
151            if (pkValue == null)
152            {
153                throw new TorqueException(
154                        "The value for the primary key column "
155                        + "TurbineUserGroupRolePeer.ROLE_ID"
156                        + " must be set");
157            }
158            if (pkValue.getSqlExpression() == null)
159            {
160                selectCriteria.where(
161                        TurbineUserGroupRolePeer.ROLE_ID,
162                        pkValue.getValue());
163            }
164            else
165            {
166                selectCriteria.where(
167                        TurbineUserGroupRolePeer.ROLE_ID,
168                        pkValue.getSqlExpression());
169            }
170        }
171
172
173        int rowCount = doUpdate(selectCriteria, columnValues, con);
174        return rowCount;
175    }
176
177    /**
178     * Deletes a data object, i.e. a row in a table, in the database.
179     *
180     * @param obj the data object to delete in the database, not null.
181     *
182     * @return the number of deleted rows.
183     *
184     * @throws TorqueException Any exceptions caught during processing will be
185     *         rethrown wrapped into a TorqueException.
186     */
187    public int doDelete(TurbineUserGroupRole obj) throws TorqueException
188    {
189        int result = doDelete(buildCriteria(obj.getPrimaryKey()));
190        obj.setDeleted(true);
191        return result;
192    }
193
194    /**
195     * Deletes a data object, i.e. a row in a table, in the database.
196     * This method is to be used during a transaction, otherwise use the
197     * doDelete(TurbineUserGroupRole) method.
198     *
199     * @param obj the data object to delete in the database, not null.
200     * @param con the connection to use, not null.
201     *
202     * @return the number of deleted rows.
203     *
204     * @throws TorqueException Any exceptions caught during processing will be
205     *         rethrown wrapped into a TorqueException.
206     */
207    public int doDelete(TurbineUserGroupRole obj, Connection con)
208        throws TorqueException
209    {
210        int result = doDelete(buildCriteria(obj.getPrimaryKey()), con);
211        obj.setDeleted(true);
212        return result;
213    }
214
215    /**
216     * Deletes data objects, i.e. rows in a table, in the database.
217     *
218     * @param objects the data object to delete in the database, not null,
219     *        may not contain null.
220     *
221     * @return the number of deleted rows.
222     *
223     * @throws TorqueException Any exceptions caught during processing will be
224     *         rethrown wrapped into a TorqueException.
225     */
226    public int doDelete(Collection<TurbineUserGroupRole> objects)
227            throws TorqueException
228    {
229        int result = doDelete(buildPkCriteria(objects));
230        objects.forEach(object -> object.setDeleted(true));
231        return result;
232    }
233
234    /**
235     * Deletes data objects, i.e. rows in a table, in the database.
236     * This method uses the passed connection to delete the rows;
237     * if a transaction is open in the connection, the deletion happens inside
238     * this transaction.
239     *
240     * @param objects the data objects to delete in the database, not null,
241     *        may not contain null.
242     * @param con the connection to use for deleting, not null.
243     *
244     * @return the number of deleted rows.
245     *
246     * @throws TorqueException Any exceptions caught during processing will be
247     *         rethrown wrapped into a TorqueException.
248     */
249    public int doDelete(
250            Collection<TurbineUserGroupRole> objects,
251            Connection con)
252        throws TorqueException
253    {
254        int result = doDelete(buildPkCriteria(objects), con);
255        objects.forEach(object -> object.setDeleted(true));
256        return result;
257    }
258
259    /** 
260     * Build a Criteria object which selects all objects which have a given
261     * primary key.
262     *
263     * @param pk the primary key value to build the criteria from, not null.
264     */
265    public Criteria buildCriteria(ObjectKey<?> pk)
266    {
267        Criteria criteria = new Criteria();
268        SimpleKey<?>[] keys = (SimpleKey[])pk.getValue();
269        criteria.and(TurbineUserGroupRolePeer.USER_ID, keys[0]);
270        criteria.and(TurbineUserGroupRolePeer.GROUP_ID, keys[1]);
271        criteria.and(TurbineUserGroupRolePeer.ROLE_ID, keys[2]);
272        return criteria;
273     }
274
275    /** 
276     * Build a Criteria object which selects all objects which primary keys
277     * are contained in the passed collection.
278     *
279     * @param pks the primary key values to build the criteria from, not null,
280     *        may not contain null.
281     */
282    public Criteria buildCriteria(Collection<ObjectKey<?>> pks)
283    {
284        Criteria criteria = new Criteria();
285        for (ObjectKey<?> pk : pks)
286        {
287            SimpleKey<?>[] keys = (SimpleKey[])pk.getValue();
288                Criterion c0 = new Criterion(
289                    TurbineUserGroupRolePeer.USER_ID, keys[0], Criteria.EQUAL);
290                Criterion c1 = new Criterion(
291                    TurbineUserGroupRolePeer.GROUP_ID, keys[1], Criteria.EQUAL);
292                    c0.and(c1);
293                Criterion c2 = new Criterion(
294                    TurbineUserGroupRolePeer.ROLE_ID, keys[2], Criteria.EQUAL);
295                    c1.and(c2);
296            criteria.or(c0);
297        }
298        return criteria;
299     }
300
301
302    /** 
303     * Build a Criteria object which selects all passed objects using their
304     * primary key. Objects which do not yet have a primary key are ignored.
305     *
306     * @param objects the objects to build the criteria from, not null,
307     *        may not contain null.
308     */
309    public Criteria buildPkCriteria(
310            Collection<TurbineUserGroupRole> objects)
311    {
312        return buildCriteria(objects.stream()
313                .map(object -> object.getPrimaryKey())
314                .collect(Collectors.toList()));
315    }
316
317    /** 
318     * Build a Criteria object from the data object for this peer.
319     *
320     * @param obj the object to build the criteria from, not null.
321     */
322    public Criteria buildCriteria(TurbineUserGroupRole obj)
323    {
324        Criteria criteria = new Criteria(getDatabaseName());
325        criteria.and(TurbineUserGroupRolePeer.USER_ID, obj.getUserId());
326        criteria.and(TurbineUserGroupRolePeer.GROUP_ID, obj.getGroupId());
327        criteria.and(TurbineUserGroupRolePeer.ROLE_ID, obj.getRoleId());
328        return criteria;
329    }
330
331    /** 
332     * Build a Criteria object from the data object for this peer,
333     * skipping all binary columns.
334     *
335     * @param obj the object to build the criteria from, not null.
336     */
337    public Criteria buildSelectCriteria(TurbineUserGroupRole obj)
338    {
339        Criteria criteria = new Criteria(getDatabaseName());
340        criteria.and(TurbineUserGroupRolePeer.USER_ID, obj.getUserId());
341        criteria.and(TurbineUserGroupRolePeer.GROUP_ID, obj.getGroupId());
342        criteria.and(TurbineUserGroupRolePeer.ROLE_ID, obj.getRoleId());
343        return criteria;
344    }
345
346    /** 
347     * Returns the contents of the object as ColumnValues object.
348     * Primary key columns which are generated on insertion are not
349     * added to the returned object if they still have their initial
350     * value. Also, columns which have the useDatabaseDefaultValue
351     * flag set to true are also not added to the returned object
352     * if they still have their initial value.
353     *
354     * @throws TorqueException if the table map cannot be retrieved
355     *         (should not happen).
356     */
357    public ColumnValues buildColumnValues(TurbineUserGroupRole turbineUserGroupRole)
358            throws TorqueException
359    {
360        ColumnValues columnValues = new ColumnValues();
361        columnValues.put(
362                TurbineUserGroupRolePeer.USER_ID,
363                new JdbcTypedValue(
364                    turbineUserGroupRole.getUserId(),
365                    4));
366        columnValues.put(
367                TurbineUserGroupRolePeer.GROUP_ID,
368                new JdbcTypedValue(
369                    turbineUserGroupRole.getGroupId(),
370                    4));
371        columnValues.put(
372                TurbineUserGroupRolePeer.ROLE_ID,
373                new JdbcTypedValue(
374                    turbineUserGroupRole.getRoleId(),
375                    4));
376        return columnValues;
377    }
378
379    /**
380     * retrieve object using using pk values.
381     *
382     * @param userId Integer
383     * @param groupId Integer
384     * @param roleId Integer
385     */
386    public TurbineUserGroupRole retrieveByPK(
387            Integer userId,
388            Integer groupId,
389            Integer roleId)
390        throws TorqueException
391    {
392        try (TorqueConnection connection = Transaction.begin(getDatabaseName()))
393        {
394            TurbineUserGroupRole result = retrieveByPK(
395               userId,
396               groupId,
397               roleId,
398               connection);
399            Transaction.commit(connection);
400            return result;
401        }
402    }
403
404    /**
405     * retrieve object using using pk values.
406     *
407     * @param userId Integer
408     * @param groupId Integer
409     * @param roleId Integer
410     * @param con Connection
411     */
412    public TurbineUserGroupRole retrieveByPK(
413            Integer userId,
414            Integer groupId,
415            Integer roleId,
416            Connection con) throws TorqueException
417    {
418
419        Criteria criteria = new Criteria();
420        criteria.and(TurbineUserGroupRolePeer.USER_ID, userId);
421        criteria.and(TurbineUserGroupRolePeer.GROUP_ID, groupId);
422        criteria.and(TurbineUserGroupRolePeer.ROLE_ID, roleId);
423        TurbineUserGroupRole v = doSelectSingleRecord(criteria, con);
424        if (v == null)
425        {
426            throw new NoRowsException("Failed to select a row.");
427        }
428
429        return v;
430    }
431
432    /**
433     * Retrieve a single object by pk
434     *
435     * @param pk the primary key
436     * @throws TorqueException Any exceptions caught during processing will be
437     *         rethrown wrapped into a TorqueException.
438     * @throws NoRowsException Primary key was not found in database.
439     * @throws TooManyRowsException Primary key was not found in database.
440     */
441    public TurbineUserGroupRole retrieveByPK(ObjectKey<?> pk)
442        throws TorqueException, NoRowsException, TooManyRowsException
443    {
444        try (TorqueConnection connection = Transaction.begin(getDatabaseName()))
445        {
446            TurbineUserGroupRole result = retrieveByPK(pk, connection);
447            Transaction.commit(connection);
448            return result;
449        }
450    }
451
452    /**
453     * Retrieve a single object by pk
454     *
455     * @param pk the primary key
456     * @param con the connection to use
457     * @throws TorqueException Any exceptions caught during processing will be
458     *         rethrown wrapped into a TorqueException.
459     * @throws NoRowsException Primary key was not found in database.
460     * @throws TooManyRowsException Primary key was not found in database.
461     */
462    public TurbineUserGroupRole retrieveByPK(ObjectKey<?> pk, Connection con)
463        throws TorqueException, NoRowsException, TooManyRowsException
464    {
465        Criteria criteria = buildCriteria(pk);
466        TurbineUserGroupRole v = doSelectSingleRecord(criteria, con);
467        if (v == null)
468        {
469            throw new NoRowsException("Failed to select a row.");
470        }
471
472        return v;
473    }
474
475
476    /**
477     * Retrieve multiple objects by pk.
478     *
479     * @param pks List of primary keys.
480     *        Entries in pks which do not match entries in the database are ignored.
481     *
482     * @return the list of matching objects, not null.
483     *
484     * @throws TorqueException Any exceptions caught during processing will be
485     *         rethrown wrapped into a TorqueException.
486     */
487    public List<TurbineUserGroupRole> retrieveByObjectKeys(Collection<ObjectKey<?>> pks)
488        throws TorqueException
489    {
490        try (TorqueConnection connection = Transaction.begin(getDatabaseName()))
491        {
492            List<TurbineUserGroupRole> result = retrieveByObjectKeys(pks, connection);
493            Transaction.commit(connection);
494            return result;
495        }
496    }
497
498    /**
499     * Retrieve multiple objects by pk.
500     *
501     * @param pks List of primary keys.
502     *        Entries in pks which do not match entries in the database are ignored.
503     * @param dbcon the connection to use
504     *
505     * @return the list of matching objects, not null.
506     *
507     * @throws TorqueException Any exceptions caught during processing will be
508     *         rethrown wrapped into a TorqueException.
509     */
510    public List<TurbineUserGroupRole> retrieveByObjectKeys(
511                Collection<ObjectKey<?>> pks,
512                Connection dbcon)
513            throws TorqueException
514    {
515        if (pks == null || pks.size() == 0)
516        {
517            return new ArrayList<TurbineUserGroupRole>();
518        }
519        Criteria criteria = buildCriteria(pks);
520        List<TurbineUserGroupRole> result = doSelect(criteria, dbcon);
521        return result;
522    }
523
524
525    /**
526     * Selects a collection of dbObjectClassName objects pre-filled with their
527     * TurbineUser objects.
528     *
529     * @throws TorqueException Any exceptions caught during processing will be
530     *         rethrown wrapped into a TorqueException.
531     */
532    public List<TurbineUserGroupRole> doSelectJoinTurbineUser(Criteria criteria)
533        throws TorqueException
534    {
535        try (TorqueConnection connection = Transaction.begin(getDatabaseName()))
536        {
537            List<TurbineUserGroupRole> result
538                    = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria, connection);
539            Transaction.commit(connection);
540            return result;
541        }
542    }
543
544    /**
545     * Selects a collection of TurbineUserGroupRole objects pre-filled with their
546     * TurbineUser objects.
547     *
548     * @throws TorqueException Any exceptions caught during processing will be
549     *         rethrown wrapped into a TorqueException.
550     */
551    public List<TurbineUserGroupRole> doSelectJoinTurbineUser(
552            Criteria criteria, Connection conn)
553        throws TorqueException
554    {
555        setDbName(criteria);
556
557        addSelectColumns(criteria);
558        org.apache.fulcrum.security.torque.om.TurbineUserPeer.addSelectColumns(criteria);
559
560        CompositeMapper compositeMapper = new CompositeMapper();
561        compositeMapper.addMapper(
562                new TurbineUserGroupRoleRecordMapper(),
563                0);
564        compositeMapper.addMapper(
565                new TurbineUserRecordMapper(),
566                TurbineUserGroupRolePeer.numColumns);
567        criteria.addJoin(TurbineUserGroupRolePeer.USER_ID,
568            org.apache.fulcrum.security.torque.om.TurbineUserPeer.USER_ID);
569
570        correctBooleans(criteria);
571
572        List<TurbineUserGroupRole> result = new ArrayList<TurbineUserGroupRole>();
573        List<List<Object>> rawResult = doSelect(
574                criteria, compositeMapper, conn);
575        for (List<Object> rawResultRow : rawResult)
576        {
577            TurbineUserGroupRole obj1 = (TurbineUserGroupRole) rawResultRow.get(0);
578            TurbineUser obj2 = (TurbineUser) rawResultRow.get(1);
579
580            boolean newObject = true;
581            for (int j = 0; j < result.size(); j++)
582            {
583                TurbineUserGroupRole temp_obj1 = result.get(j);
584                org.apache.fulcrum.security.torque.om.TurbineUser temp_obj2 = temp_obj1.getTurbineUser();
585                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
586                {
587                    newObject = false;
588                    temp_obj2.addTurbineUserGroupRole(obj1);
589                    break;
590                }
591            }
592            if (newObject)
593            {
594                obj2.initTurbineUserGroupRoles();
595                obj2.addTurbineUserGroupRole(obj1);
596            }
597            result.add(obj1);
598        }
599        return result;
600    }
601    /**
602     * Selects a collection of dbObjectClassName objects pre-filled with their
603     * TurbineGroup objects.
604     *
605     * @throws TorqueException Any exceptions caught during processing will be
606     *         rethrown wrapped into a TorqueException.
607     */
608    public List<TurbineUserGroupRole> doSelectJoinTurbineGroup(Criteria criteria)
609        throws TorqueException
610    {
611        try (TorqueConnection connection = Transaction.begin(getDatabaseName()))
612        {
613            List<TurbineUserGroupRole> result
614                    = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria, connection);
615            Transaction.commit(connection);
616            return result;
617        }
618    }
619
620    /**
621     * Selects a collection of TurbineUserGroupRole objects pre-filled with their
622     * TurbineGroup objects.
623     *
624     * @throws TorqueException Any exceptions caught during processing will be
625     *         rethrown wrapped into a TorqueException.
626     */
627    public List<TurbineUserGroupRole> doSelectJoinTurbineGroup(
628            Criteria criteria, Connection conn)
629        throws TorqueException
630    {
631        setDbName(criteria);
632
633        addSelectColumns(criteria);
634        org.apache.fulcrum.security.torque.om.TurbineGroupPeer.addSelectColumns(criteria);
635
636        CompositeMapper compositeMapper = new CompositeMapper();
637        compositeMapper.addMapper(
638                new TurbineUserGroupRoleRecordMapper(),
639                0);
640        compositeMapper.addMapper(
641                new TurbineGroupRecordMapper(),
642                TurbineUserGroupRolePeer.numColumns);
643        criteria.addJoin(TurbineUserGroupRolePeer.GROUP_ID,
644            org.apache.fulcrum.security.torque.om.TurbineGroupPeer.GROUP_ID);
645
646        correctBooleans(criteria);
647
648        List<TurbineUserGroupRole> result = new ArrayList<TurbineUserGroupRole>();
649        List<List<Object>> rawResult = doSelect(
650                criteria, compositeMapper, conn);
651        for (List<Object> rawResultRow : rawResult)
652        {
653            TurbineUserGroupRole obj1 = (TurbineUserGroupRole) rawResultRow.get(0);
654            TurbineGroup obj2 = (TurbineGroup) rawResultRow.get(1);
655
656            boolean newObject = true;
657            for (int j = 0; j < result.size(); j++)
658            {
659                TurbineUserGroupRole temp_obj1 = result.get(j);
660                org.apache.fulcrum.security.torque.om.TurbineGroup temp_obj2 = temp_obj1.getTurbineGroup();
661                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
662                {
663                    newObject = false;
664                    temp_obj2.addTurbineUserGroupRole(obj1);
665                    break;
666                }
667            }
668            if (newObject)
669            {
670                obj2.initTurbineUserGroupRoles();
671                obj2.addTurbineUserGroupRole(obj1);
672            }
673            result.add(obj1);
674        }
675        return result;
676    }
677    /**
678     * Selects a collection of dbObjectClassName objects pre-filled with their
679     * TurbineRole objects.
680     *
681     * @throws TorqueException Any exceptions caught during processing will be
682     *         rethrown wrapped into a TorqueException.
683     */
684    public List<TurbineUserGroupRole> doSelectJoinTurbineRole(Criteria criteria)
685        throws TorqueException
686    {
687        try (TorqueConnection connection = Transaction.begin(getDatabaseName()))
688        {
689            List<TurbineUserGroupRole> result
690                    = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria, connection);
691            Transaction.commit(connection);
692            return result;
693        }
694    }
695
696    /**
697     * Selects a collection of TurbineUserGroupRole objects pre-filled with their
698     * TurbineRole objects.
699     *
700     * @throws TorqueException Any exceptions caught during processing will be
701     *         rethrown wrapped into a TorqueException.
702     */
703    public List<TurbineUserGroupRole> doSelectJoinTurbineRole(
704            Criteria criteria, Connection conn)
705        throws TorqueException
706    {
707        setDbName(criteria);
708
709        addSelectColumns(criteria);
710        org.apache.fulcrum.security.torque.om.TurbineRolePeer.addSelectColumns(criteria);
711
712        CompositeMapper compositeMapper = new CompositeMapper();
713        compositeMapper.addMapper(
714                new TurbineUserGroupRoleRecordMapper(),
715                0);
716        compositeMapper.addMapper(
717                new TurbineRoleRecordMapper(),
718                TurbineUserGroupRolePeer.numColumns);
719        criteria.addJoin(TurbineUserGroupRolePeer.ROLE_ID,
720            org.apache.fulcrum.security.torque.om.TurbineRolePeer.ROLE_ID);
721
722        correctBooleans(criteria);
723
724        List<TurbineUserGroupRole> result = new ArrayList<TurbineUserGroupRole>();
725        List<List<Object>> rawResult = doSelect(
726                criteria, compositeMapper, conn);
727        for (List<Object> rawResultRow : rawResult)
728        {
729            TurbineUserGroupRole obj1 = (TurbineUserGroupRole) rawResultRow.get(0);
730            TurbineRole obj2 = (TurbineRole) rawResultRow.get(1);
731
732            boolean newObject = true;
733            for (int j = 0; j < result.size(); j++)
734            {
735                TurbineUserGroupRole temp_obj1 = result.get(j);
736                org.apache.fulcrum.security.torque.om.TurbineRole temp_obj2 = temp_obj1.getTurbineRole();
737                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
738                {
739                    newObject = false;
740                    temp_obj2.addTurbineUserGroupRole(obj1);
741                    break;
742                }
743            }
744            if (newObject)
745            {
746                obj2.initTurbineUserGroupRoles();
747                obj2.addTurbineUserGroupRole(obj1);
748            }
749            result.add(obj1);
750        }
751        return result;
752    }
753
754    /**
755     * selects a collection of TurbineUserGroupRole objects pre-filled with
756     * all related objects.
757     *
758     * This method is protected by default in order to keep the public
759     * api reasonable.  You can provide public methods for those you
760     * actually need in TurbineUserGroupRolePeerImpl.
761     *
762     * @throws TorqueException Any exceptions caught during processing will be
763     *         rethrown wrapped into a TorqueException.
764     */
765    protected List<TurbineUserGroupRole> doSelectJoinAllExceptTurbineUser(Criteria criteria)
766        throws TorqueException
767    {
768        try (TorqueConnection connection = Transaction.begin(getDatabaseName()))
769        {
770            List<TurbineUserGroupRole> result
771                    = TurbineUserGroupRolePeer.doSelectJoinAllExceptTurbineUser(criteria, connection);
772            Transaction.commit(connection);
773            return result;
774        }
775    }
776
777    /**
778     * selects a collection of TurbineUserGroupRole objects pre-filled with
779     * related objects.
780     *
781     * This method is protected by default in order to keep the public
782     * api reasonable.  You can provide public methods for those you
783     * actually need in TurbineUserGroupRolePeerImpl.
784     *
785     * @throws TorqueException Any exceptions caught during processing will be
786     *         rethrown wrapped into a TorqueException.
787     */
788    protected List<TurbineUserGroupRole> doSelectJoinAllExceptTurbineUser(Criteria criteria, Connection conn)
789        throws TorqueException
790    {
791        setDbName(criteria);
792
793        CompositeMapper compositeMapper = new CompositeMapper();
794        compositeMapper.addMapper(new TurbineUserGroupRoleRecordMapper(), 0);
795        TurbineUserGroupRolePeer.addSelectColumns(criteria);
796        int offset = TurbineUserGroupRolePeer.numColumns;
797 
798        org.apache.fulcrum.security.torque.om.TurbineGroupPeer.addSelectColumns(criteria);
799        criteria.addJoin(TurbineUserGroupRolePeer.GROUP_ID, org.apache.fulcrum.security.torque.om.TurbineGroupPeer.GROUP_ID);
800        compositeMapper.addMapper(new TurbineGroupRecordMapper(), offset);
801        offset = offset + org.apache.fulcrum.security.torque.om.TurbineGroupPeer.numColumns;
802 
803        org.apache.fulcrum.security.torque.om.TurbineRolePeer.addSelectColumns(criteria);
804        criteria.addJoin(TurbineUserGroupRolePeer.ROLE_ID, org.apache.fulcrum.security.torque.om.TurbineRolePeer.ROLE_ID);
805        compositeMapper.addMapper(new TurbineRoleRecordMapper(), offset);
806        offset = offset + org.apache.fulcrum.security.torque.om.TurbineRolePeer.numColumns;
807
808        correctBooleans(criteria);
809
810        List<TurbineUserGroupRole> result = new ArrayList<TurbineUserGroupRole>();
811        List<List<Object>> rawResult = doSelect(
812                criteria, compositeMapper, conn);
813        for (List<Object> rawResultRow : rawResult)
814        {
815            TurbineUserGroupRole turbineUserGroupRole = (TurbineUserGroupRole) rawResultRow.get(0);
816
817            org.apache.fulcrum.security.torque.om.TurbineGroup obj1 = (org.apache.fulcrum.security.torque.om.TurbineGroup) rawResultRow.get(1);
818            boolean newObject = true;
819            for (int j = 0; j < result.size(); j++)
820            {
821                org.apache.fulcrum.security.torque.om.TurbineUserGroupRole temp_turbineUserGroupRole = result.get(j);
822                org.apache.fulcrum.security.torque.om.TurbineGroup temp_obj1 = temp_turbineUserGroupRole.getTurbineGroup();
823                if (temp_obj1.getPrimaryKey().equals(obj1.getPrimaryKey()))
824                {
825                    newObject = false;
826                    temp_obj1.addTurbineUserGroupRole(turbineUserGroupRole);
827                    break;
828                }
829            }
830            if (newObject)
831            {
832                obj1.initTurbineUserGroupRoles();
833                obj1.addTurbineUserGroupRole(turbineUserGroupRole);
834            }
835
836            org.apache.fulcrum.security.torque.om.TurbineRole obj2 = (org.apache.fulcrum.security.torque.om.TurbineRole) rawResultRow.get(2);
837            newObject = true;
838            for (int j = 0; j < result.size(); j++)
839            {
840                org.apache.fulcrum.security.torque.om.TurbineUserGroupRole temp_turbineUserGroupRole = result.get(j);
841                org.apache.fulcrum.security.torque.om.TurbineRole temp_obj2 = temp_turbineUserGroupRole.getTurbineRole();
842                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
843                {
844                    newObject = false;
845                    temp_obj2.addTurbineUserGroupRole(turbineUserGroupRole);
846                    break;
847                }
848            }
849            if (newObject)
850            {
851                obj2.initTurbineUserGroupRoles();
852                obj2.addTurbineUserGroupRole(turbineUserGroupRole);
853            }
854            result.add(turbineUserGroupRole);
855        }
856        return result;
857    }
858    /**
859     * selects a collection of TurbineUserGroupRole objects pre-filled with
860     * all related objects.
861     *
862     * This method is protected by default in order to keep the public
863     * api reasonable.  You can provide public methods for those you
864     * actually need in TurbineUserGroupRolePeerImpl.
865     *
866     * @throws TorqueException Any exceptions caught during processing will be
867     *         rethrown wrapped into a TorqueException.
868     */
869    protected List<TurbineUserGroupRole> doSelectJoinAllExceptTurbineGroup(Criteria criteria)
870        throws TorqueException
871    {
872        try (TorqueConnection connection = Transaction.begin(getDatabaseName()))
873        {
874            List<TurbineUserGroupRole> result
875                    = TurbineUserGroupRolePeer.doSelectJoinAllExceptTurbineGroup(criteria, connection);
876            Transaction.commit(connection);
877            return result;
878        }
879    }
880
881    /**
882     * selects a collection of TurbineUserGroupRole objects pre-filled with
883     * related objects.
884     *
885     * This method is protected by default in order to keep the public
886     * api reasonable.  You can provide public methods for those you
887     * actually need in TurbineUserGroupRolePeerImpl.
888     *
889     * @throws TorqueException Any exceptions caught during processing will be
890     *         rethrown wrapped into a TorqueException.
891     */
892    protected List<TurbineUserGroupRole> doSelectJoinAllExceptTurbineGroup(Criteria criteria, Connection conn)
893        throws TorqueException
894    {
895        setDbName(criteria);
896
897        CompositeMapper compositeMapper = new CompositeMapper();
898        compositeMapper.addMapper(new TurbineUserGroupRoleRecordMapper(), 0);
899        TurbineUserGroupRolePeer.addSelectColumns(criteria);
900        int offset = TurbineUserGroupRolePeer.numColumns;
901 
902        org.apache.fulcrum.security.torque.om.TurbineUserPeer.addSelectColumns(criteria);
903        criteria.addJoin(TurbineUserGroupRolePeer.USER_ID, org.apache.fulcrum.security.torque.om.TurbineUserPeer.USER_ID);
904        compositeMapper.addMapper(new TurbineUserRecordMapper(), offset);
905        offset = offset + org.apache.fulcrum.security.torque.om.TurbineUserPeer.numColumns;
906 
907        org.apache.fulcrum.security.torque.om.TurbineRolePeer.addSelectColumns(criteria);
908        criteria.addJoin(TurbineUserGroupRolePeer.ROLE_ID, org.apache.fulcrum.security.torque.om.TurbineRolePeer.ROLE_ID);
909        compositeMapper.addMapper(new TurbineRoleRecordMapper(), offset);
910        offset = offset + org.apache.fulcrum.security.torque.om.TurbineRolePeer.numColumns;
911
912        correctBooleans(criteria);
913
914        List<TurbineUserGroupRole> result = new ArrayList<TurbineUserGroupRole>();
915        List<List<Object>> rawResult = doSelect(
916                criteria, compositeMapper, conn);
917        for (List<Object> rawResultRow : rawResult)
918        {
919            TurbineUserGroupRole turbineUserGroupRole = (TurbineUserGroupRole) rawResultRow.get(0);
920
921            org.apache.fulcrum.security.torque.om.TurbineUser obj1 = (org.apache.fulcrum.security.torque.om.TurbineUser) rawResultRow.get(1);
922            boolean newObject = true;
923            for (int j = 0; j < result.size(); j++)
924            {
925                org.apache.fulcrum.security.torque.om.TurbineUserGroupRole temp_turbineUserGroupRole = result.get(j);
926                org.apache.fulcrum.security.torque.om.TurbineUser temp_obj1 = temp_turbineUserGroupRole.getTurbineUser();
927                if (temp_obj1.getPrimaryKey().equals(obj1.getPrimaryKey()))
928                {
929                    newObject = false;
930                    temp_obj1.addTurbineUserGroupRole(turbineUserGroupRole);
931                    break;
932                }
933            }
934            if (newObject)
935            {
936                obj1.initTurbineUserGroupRoles();
937                obj1.addTurbineUserGroupRole(turbineUserGroupRole);
938            }
939
940            org.apache.fulcrum.security.torque.om.TurbineRole obj2 = (org.apache.fulcrum.security.torque.om.TurbineRole) rawResultRow.get(2);
941            newObject = true;
942            for (int j = 0; j < result.size(); j++)
943            {
944                org.apache.fulcrum.security.torque.om.TurbineUserGroupRole temp_turbineUserGroupRole = result.get(j);
945                org.apache.fulcrum.security.torque.om.TurbineRole temp_obj2 = temp_turbineUserGroupRole.getTurbineRole();
946                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
947                {
948                    newObject = false;
949                    temp_obj2.addTurbineUserGroupRole(turbineUserGroupRole);
950                    break;
951                }
952            }
953            if (newObject)
954            {
955                obj2.initTurbineUserGroupRoles();
956                obj2.addTurbineUserGroupRole(turbineUserGroupRole);
957            }
958            result.add(turbineUserGroupRole);
959        }
960        return result;
961    }
962    /**
963     * selects a collection of TurbineUserGroupRole objects pre-filled with
964     * all related objects.
965     *
966     * This method is protected by default in order to keep the public
967     * api reasonable.  You can provide public methods for those you
968     * actually need in TurbineUserGroupRolePeerImpl.
969     *
970     * @throws TorqueException Any exceptions caught during processing will be
971     *         rethrown wrapped into a TorqueException.
972     */
973    protected List<TurbineUserGroupRole> doSelectJoinAllExceptTurbineRole(Criteria criteria)
974        throws TorqueException
975    {
976        try (TorqueConnection connection = Transaction.begin(getDatabaseName()))
977        {
978            List<TurbineUserGroupRole> result
979                    = TurbineUserGroupRolePeer.doSelectJoinAllExceptTurbineRole(criteria, connection);
980            Transaction.commit(connection);
981            return result;
982        }
983    }
984
985    /**
986     * selects a collection of TurbineUserGroupRole objects pre-filled with
987     * related objects.
988     *
989     * This method is protected by default in order to keep the public
990     * api reasonable.  You can provide public methods for those you
991     * actually need in TurbineUserGroupRolePeerImpl.
992     *
993     * @throws TorqueException Any exceptions caught during processing will be
994     *         rethrown wrapped into a TorqueException.
995     */
996    protected List<TurbineUserGroupRole> doSelectJoinAllExceptTurbineRole(Criteria criteria, Connection conn)
997        throws TorqueException
998    {
999        setDbName(criteria);
1000
1001        CompositeMapper compositeMapper = new CompositeMapper();
1002        compositeMapper.addMapper(new TurbineUserGroupRoleRecordMapper(), 0);
1003        TurbineUserGroupRolePeer.addSelectColumns(criteria);
1004        int offset = TurbineUserGroupRolePeer.numColumns;
1005 
1006        org.apache.fulcrum.security.torque.om.TurbineUserPeer.addSelectColumns(criteria);
1007        criteria.addJoin(TurbineUserGroupRolePeer.USER_ID, org.apache.fulcrum.security.torque.om.TurbineUserPeer.USER_ID);
1008        compositeMapper.addMapper(new TurbineUserRecordMapper(), offset);
1009        offset = offset + org.apache.fulcrum.security.torque.om.TurbineUserPeer.numColumns;
1010 
1011        org.apache.fulcrum.security.torque.om.TurbineGroupPeer.addSelectColumns(criteria);
1012        criteria.addJoin(TurbineUserGroupRolePeer.GROUP_ID, org.apache.fulcrum.security.torque.om.TurbineGroupPeer.GROUP_ID);
1013        compositeMapper.addMapper(new TurbineGroupRecordMapper(), offset);
1014        offset = offset + org.apache.fulcrum.security.torque.om.TurbineGroupPeer.numColumns;
1015
1016        correctBooleans(criteria);
1017
1018        List<TurbineUserGroupRole> result = new ArrayList<TurbineUserGroupRole>();
1019        List<List<Object>> rawResult = doSelect(
1020                criteria, compositeMapper, conn);
1021        for (List<Object> rawResultRow : rawResult)
1022        {
1023            TurbineUserGroupRole turbineUserGroupRole = (TurbineUserGroupRole) rawResultRow.get(0);
1024
1025            org.apache.fulcrum.security.torque.om.TurbineUser obj1 = (org.apache.fulcrum.security.torque.om.TurbineUser) rawResultRow.get(1);
1026            boolean newObject = true;
1027            for (int j = 0; j < result.size(); j++)
1028            {
1029                org.apache.fulcrum.security.torque.om.TurbineUserGroupRole temp_turbineUserGroupRole = result.get(j);
1030                org.apache.fulcrum.security.torque.om.TurbineUser temp_obj1 = temp_turbineUserGroupRole.getTurbineUser();
1031                if (temp_obj1.getPrimaryKey().equals(obj1.getPrimaryKey()))
1032                {
1033                    newObject = false;
1034                    temp_obj1.addTurbineUserGroupRole(turbineUserGroupRole);
1035                    break;
1036                }
1037            }
1038            if (newObject)
1039            {
1040                obj1.initTurbineUserGroupRoles();
1041                obj1.addTurbineUserGroupRole(turbineUserGroupRole);
1042            }
1043
1044            org.apache.fulcrum.security.torque.om.TurbineGroup obj2 = (org.apache.fulcrum.security.torque.om.TurbineGroup) rawResultRow.get(2);
1045            newObject = true;
1046            for (int j = 0; j < result.size(); j++)
1047            {
1048                org.apache.fulcrum.security.torque.om.TurbineUserGroupRole temp_turbineUserGroupRole = result.get(j);
1049                org.apache.fulcrum.security.torque.om.TurbineGroup temp_obj2 = temp_turbineUserGroupRole.getTurbineGroup();
1050                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1051                {
1052                    newObject = false;
1053                    temp_obj2.addTurbineUserGroupRole(turbineUserGroupRole);
1054                    break;
1055                }
1056            }
1057            if (newObject)
1058            {
1059                obj2.initTurbineUserGroupRoles();
1060                obj2.addTurbineUserGroupRole(turbineUserGroupRole);
1061            }
1062            result.add(turbineUserGroupRole);
1063        }
1064        return result;
1065    }
1066
1067
1068
1069}