001package org.apache.fulcrum.security.torque.om;
002
003import java.io.Serializable;
004import java.sql.Connection;
005import java.util.ArrayList;
006import java.util.List;
007import java.util.Objects;
008
009import org.apache.torque.TorqueException;
010import org.apache.torque.map.TableMap;
011import org.apache.torque.om.NumberKey;
012import org.apache.torque.om.ObjectKey;
013import org.apache.torque.om.SimpleKey;
014import org.apache.torque.om.Persistent;
015import org.apache.torque.criteria.Criteria;
016import org.apache.torque.util.TorqueConnection;
017import org.apache.torque.util.Transaction;
018
019/**
020 * This class was autogenerated by Torque on:
021 *
022 * [Thu Nov 04 13:34:21 CET 2021]
023 *
024 * You should not use this class directly.  It should not even be
025 * extended; all references should be to TorqueTurbinePermission
026 */
027@SuppressWarnings("unused")
028public abstract class BaseTorqueTurbinePermission extends org.apache.fulcrum.security.torque.turbine.FulcrumAbstractTurbinePermission
029    implements Persistent, Serializable
030{
031    /** Serial version */
032    private static final long serialVersionUID = 1636029261918L;
033
034
035
036    /** Defines the entityId field. */
037    private Integer entityId = null;
038
039    /** Defines the entityName field. */
040    private String entityName = null;
041
042    /** Whether this object was modified after loading or after last save. */
043    private boolean modified = true;
044
045    /** 
046     * Whether this object was loaded from the database or already saved 
047     * (false) or whether it is not yet in the database(true).
048     */
049    private boolean isNew = true;
050
051    /** Flag which indicates whether this object is currently saving. */
052    private boolean saving = false;
053
054    /** 
055     * Flag which indicates whether this object is currently loaded
056     * from the database. 
057     */
058    private boolean loading = false;
059
060    /** 
061     * Flag which indicates whether this object was deleted from the database.
062     * Note that this flags does not always display the current database state,
063     * there is no magical connection between this flag and the database.
064     */
065    private boolean deleted = false;
066
067
068
069    /** Defines the collTorqueTurbineRolePermissions field. */
070    protected List<TorqueTurbineRolePermission> collTorqueTurbineRolePermissions = null;
071
072
073
074    /**
075     * Get the value of entityId.
076     *
077     * @return the value of entityId as Integer
078     */
079    public Integer getEntityId() 
080    {
081        
082        return entityId;
083    }
084
085    /**
086     * Set the value of entityId.
087     *
088     * @param v new value of entityId
089     */
090    public void setEntityId(Integer v)
091    {
092        if (!Objects.equals(this.entityId, v))
093        {
094            setModified(true);
095        }
096
097        this.entityId = v;
098
099        // update associated objects in collTorqueTurbineRolePermissions 
100        if (collTorqueTurbineRolePermissions != null)
101        {
102            for (TorqueTurbineRolePermission element : collTorqueTurbineRolePermissions)
103            {
104                element.setPermissionId(v);
105            }
106        }
107
108    }
109    
110    /**
111     * Get the value of entityName.
112     *
113     * @return the value of entityName as String
114     */
115    public String getEntityName() 
116    {
117        
118        return entityName;
119    }
120
121    /**
122     * Set the value of entityName.
123     *
124     * @param v new value of entityName
125     */
126    public void setEntityName(String v)
127    {
128        if (!Objects.equals(this.entityName, v))
129        {
130            setModified(true);
131        }
132
133        this.entityName = v;
134
135
136    }
137    
138
139    /**
140     * Returns whether the object has ever been saved.  This will
141     * be false, if the object was retrieved from storage or was created
142     * and then saved.
143     *
144     * @return true, if the object has never been persisted.
145     */
146    public boolean isNew()
147    {
148        return isNew;
149    }
150
151    /**
152     * Sets whether the object has ever been saved.
153     *
154     * @param isNew true if the object has never been saved, false otherwise.
155     */
156    public void setNew(boolean isNew)
157    {
158        this.isNew = isNew;
159    }
160
161    /**
162     * Returns whether the object has been modified.
163     *
164     * @return True if the object has been modified.
165     */
166    public boolean isModified()
167    {
168        return modified;
169    }
170
171    /**
172     * Sets whether the object has been modified.
173     *
174     * @param modified true if the object has been modified, false otherwise.
175     */
176    public void setModified(boolean modified)
177    {
178        this.modified = modified;
179    }
180
181    /**
182     * Sets the modified state for the object to be false.
183     */
184    public void resetModified()
185    {
186        modified = false;
187    }
188
189
190    /**
191     * Returns whether this object is currently saving.
192     *
193     * @return true if this object is currently saving, false otherwise.
194     */
195    public boolean isSaving()
196    {
197        return saving;
198    }
199
200    /**
201     * Sets whether this object is currently saving.
202     *
203     * @param saving true if this object is currently saving, false otherwise.
204     */
205    public void setSaving(boolean saving)
206    {
207        this.saving = saving;
208    }
209
210
211    /**
212     * Returns whether this object is currently being loaded from the database.
213     *
214     * @return true if this object is currently loading, false otherwise.
215     */
216    public boolean isLoading()
217    {
218        return loading;
219    }
220
221    /**
222     * Sets whether this object is currently being loaded from the database.
223     *
224     * @param loading true if this object is currently loading, false otherwise.
225     */
226    public void setLoading(boolean loading)
227    {
228        this.loading = loading;
229    }
230
231
232    /**
233     * Returns whether this object was deleted from the database.
234     * Note that this getter does not automatically reflect database state,
235     * it will be set to true by Torque if doDelete() was called with this 
236     * object. Bulk deletes and deletes via primary key do not change
237     * this flag. Also, if doDelete() was called on an object which does
238     * not exist in the database, the deleted flag is set to true even if
239     * it was not deleted.
240     *
241     * @return true if this object was deleted, false otherwise.
242     */
243    public boolean isDeleted()
244    {
245        return deleted;
246    }
247
248    /**
249     * Sets whether this object was deleted from the database.
250     *
251     * @param deleted true if this object was deleted, false otherwise.
252     */
253    public void setDeleted(boolean deleted)
254    {
255        this.deleted = deleted;
256    }
257
258
259
260
261    /**
262     * Initializes the cache collTorqueTurbineRolePermissions for referenced objects.
263     * This, means, if collTorqueTurbineRolePermissions is null when this operation is called, it is
264     * initialized with an empty collection, otherwise it remains unchanged. 
265     *
266     * @return the (possibly new) content of the field collTorqueTurbineRolePermissions, not null.
267     */
268    public List<TorqueTurbineRolePermission> initTorqueTurbineRolePermissions()
269    {
270        if (collTorqueTurbineRolePermissions == null)
271        {
272            collTorqueTurbineRolePermissions = new ArrayList<TorqueTurbineRolePermission>();
273        }
274        return collTorqueTurbineRolePermissions;
275    }
276
277    /**
278     * Checks whether the cache collTorqueTurbineRolePermissions for referenced objects has either been
279     * loaded from the database or has been manually initialized.
280     *
281     * @return boolean true if initialized
282     */
283    public boolean isTorqueTurbineRolePermissionsInitialized()
284    {
285        return (collTorqueTurbineRolePermissions != null);
286    }
287
288
289    /**
290     * Method called to associate a TorqueTurbineRolePermission object to this object
291     * through the collTorqueTurbineRolePermissions foreign key attribute.
292     * If the associated objects were not retrieved before
293     * and this object is not new, the associated objects are retrieved
294     * from the database before adding the <code>toAdd</code> object.
295     *
296     * @param toAdd the object to add to the associated objects, not null.
297     *
298     * @throws TorqueException if retrieval of the associated objects fails.
299     * @throws NullPointerException if toAdd is null.
300     */
301    public void addTorqueTurbineRolePermission(TorqueTurbineRolePermission toAdd)
302        throws TorqueException
303    {
304        toAdd.setTorqueTurbinePermission((TorqueTurbinePermission) this);
305        getTorqueTurbineRolePermissions().add(toAdd);
306    }
307
308    /**
309     * Method called to associate a TorqueTurbineRolePermission object to this object
310     * through the collTorqueTurbineRolePermissions foreign key attribute using connection.
311     *
312     * @param l TorqueTurbineRolePermission
313     * @throws TorqueException if retrieval of the associated objects fails.
314     */
315    public void addTorqueTurbineRolePermission(TorqueTurbineRolePermission l, Connection con) throws TorqueException
316    {
317        getTorqueTurbineRolePermissions(con).add(l);
318        l.setTorqueTurbinePermission((TorqueTurbinePermission) this);
319    }
320    
321    /**
322     * Method called to reset the cache of TorqueTurbineRolePermission objects
323     * which are related through the collTorqueTurbineRolePermissions foreign key attribute.
324     */
325    public void resetTorqueTurbineRolePermission()
326    {
327        collTorqueTurbineRolePermissions = null;
328    }
329
330
331    /**
332     * The criteria used to select the current contents of collTorqueTurbineRolePermissions
333     */
334    private Criteria lastTorqueTurbineRolePermissionCriteria = null;
335
336    /**
337     * If this collection has already been initialized, returns
338     * the collection. Otherwise returns the results of
339     * getTorqueTurbineRolePermissions(new Criteria())
340     *
341     * @return the collection of associated objects
342     * @throws TorqueException
343     */
344    public List<TorqueTurbineRolePermission> getTorqueTurbineRolePermissions()
345        throws TorqueException
346    {
347        if (collTorqueTurbineRolePermissions == null)
348        {
349            collTorqueTurbineRolePermissions = getTorqueTurbineRolePermissions(new Criteria());
350            for (TorqueTurbineRolePermission torqueTurbineRolePermission : collTorqueTurbineRolePermissions)
351            {
352                torqueTurbineRolePermission.setTorqueTurbinePermission((TorqueTurbinePermission) this);
353            }
354        }
355        return collTorqueTurbineRolePermissions;
356    }
357
358    /**
359     * If this collection has already been initialized with
360     * an identical criteria, it returns the collection.
361     * Otherwise if this BaseTorqueTurbinePermission has previously
362     * been saved, it will retrieve related collTorqueTurbineRolePermissions from storage.
363     * If this BaseTorqueTurbinePermission is new, it will return
364     * an empty collection or the current collection, the criteria
365     * is ignored on a new object.
366     *
367     * @throws TorqueException If a problem occurs with the get[criteria] method.     
368     */
369    public List<TorqueTurbineRolePermission> getTorqueTurbineRolePermissions(Criteria criteria) throws TorqueException
370    {
371        if (collTorqueTurbineRolePermissions == null)
372        {
373            if (isNew())
374            {
375               initTorqueTurbineRolePermissions();
376            }
377            else
378            {
379                criteria.and(org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermissionPeer.PERMISSION_ID, getEntityId());
380                collTorqueTurbineRolePermissions = org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermissionPeer.doSelect(criteria);
381                for (TorqueTurbineRolePermission torqueTurbineRolePermission : collTorqueTurbineRolePermissions)
382                {
383                    torqueTurbineRolePermission.setTorqueTurbinePermission((TorqueTurbinePermission) this);
384                }
385            }
386        }
387        else
388        {
389            // criteria has no effect for a new object
390            if (!isNew())
391            {
392                // the following code is to determine if a new query is
393                // called for.  If the criteria is the same as the last
394                // one, just return the collection.
395                criteria.and(org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermissionPeer.PERMISSION_ID, getEntityId());
396                if (lastTorqueTurbineRolePermissionCriteria == null
397                        || !lastTorqueTurbineRolePermissionCriteria.equals(criteria))
398                {
399                    collTorqueTurbineRolePermissions = org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermissionPeer.doSelect(criteria);
400                    for (TorqueTurbineRolePermission torqueTurbineRolePermission : collTorqueTurbineRolePermissions)
401                    {
402                        torqueTurbineRolePermission.setTorqueTurbinePermission((TorqueTurbinePermission) this);
403                    }
404                }
405            }
406        }
407        lastTorqueTurbineRolePermissionCriteria = criteria;
408        return collTorqueTurbineRolePermissions;
409    }
410
411    /**
412     * If this collection has already been initialized, returns
413     * the collection. Otherwise returns the results of
414     * getTorqueTurbineRolePermissions(new Criteria(),Connection)
415     * This method takes in the Connection also as input so that
416     * referenced objects can also be obtained using a Connection
417     * that is taken as input
418     *
419     * @param con the Connection
420     * @return List<TorqueTurbineRolePermission> results of the collection
421     * @throws TorqueException If a problem occurs with the get[connection] method.
422     */
423    public List<TorqueTurbineRolePermission> getTorqueTurbineRolePermissions(Connection con) throws TorqueException
424    {
425        if (collTorqueTurbineRolePermissions == null)
426        {
427            collTorqueTurbineRolePermissions = getTorqueTurbineRolePermissions(new Criteria(), con);
428            for (TorqueTurbineRolePermission torqueTurbineRolePermission : collTorqueTurbineRolePermissions)
429            {
430                torqueTurbineRolePermission.setTorqueTurbinePermission((TorqueTurbinePermission) this);
431            }
432        }
433        return collTorqueTurbineRolePermissions;
434    }
435
436    /**
437     * If this collection has already been initialized with
438     * an identical criteria, it returns the collection.
439     * Otherwise if this BaseTorqueTurbinePermission has previously
440     * been saved, it will retrieve the related TorqueTurbineRolePermission Objects
441     * from storage.
442     * If this BaseTorqueTurbinePermission is new, it will return
443     * an empty collection or the current collection, the criteria
444     * is ignored on a new object.
445     * This method takes in the Connection also as input so that
446     * referenced objects can also be obtained using a Connection
447     * that is taken as input
448     *
449     * @param con the Connection
450     * @return List<TorqueTurbineRolePermission> results of the collection
451     * @throws TorqueException If a problem occurs with the get[connection] method.
452     */
453    public List<TorqueTurbineRolePermission> getTorqueTurbineRolePermissions(Criteria criteria, Connection con)
454            throws TorqueException
455    {
456        if (collTorqueTurbineRolePermissions == null)
457        {
458            if (isNew())
459            {
460               initTorqueTurbineRolePermissions();
461            }
462            else
463            {
464                criteria.and(org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermissionPeer.PERMISSION_ID, getEntityId());
465                collTorqueTurbineRolePermissions = org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermissionPeer.doSelect(criteria, con);
466                for (TorqueTurbineRolePermission torqueTurbineRolePermission : collTorqueTurbineRolePermissions)
467                {
468                    torqueTurbineRolePermission.setTorqueTurbinePermission((TorqueTurbinePermission) this);
469                }
470            }
471        }
472        else
473        {
474             // criteria has no effect for a new object
475            if (!isNew())
476            {
477                // the following code is to determine if a new query is
478                // called for.  If the criteria is the same as the last
479                // one, just return the collection.
480                criteria.and(org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermissionPeer.PERMISSION_ID, getEntityId());
481                if (lastTorqueTurbineRolePermissionCriteria == null
482                        || !lastTorqueTurbineRolePermissionCriteria.equals(criteria))
483                {
484                    collTorqueTurbineRolePermissions = org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermissionPeer.doSelect(criteria, con);
485                    for (TorqueTurbineRolePermission torqueTurbineRolePermission : collTorqueTurbineRolePermissions)
486                    {
487                        torqueTurbineRolePermission.setTorqueTurbinePermission((TorqueTurbinePermission) this);
488                    }
489                }
490            }
491        }
492        lastTorqueTurbineRolePermissionCriteria = criteria;
493
494        return collTorqueTurbineRolePermissions;
495    }
496
497    /**
498     * If this collection has already been initialized with
499     * an identical criteria, it returns the collection.
500     * Otherwise if this BaseTorqueTurbinePermission is new, it will return
501     * an empty collection; or if this thisObjectClassName has previously
502     * been saved, it will retrieve the related objects from storage.
503     *
504     * This method is protected by default in order to keep the public
505     * api reasonable.  You can change the access modifier to public
506     * by overriding this method in the child class.
507     *
508     * @return List<TorqueTurbineRolePermission> the collection
509     * @param criteria the criteria to use when filling the collection.
510     * @throws TorqueException if associated objects are not found
511     */
512    protected List<TorqueTurbineRolePermission> getTorqueTurbineRolePermissionsJoinTorqueTurbineRole(Criteria criteria) throws TorqueException
513    {
514        try (TorqueConnection connection = Transaction.begin(criteria.getDbName()))
515        {
516            List<TorqueTurbineRolePermission> result = getTorqueTurbineRolePermissionsJoinTorqueTurbineRole(criteria, connection);
517
518            Transaction.commit(connection);
519            return result;
520        }
521    }
522
523    /**
524     * If this collection has already been initialized with
525     * an identical criteria, it returns the collection.
526     * Otherwise if this BaseTorqueTurbinePermission is new, it will return
527     * an empty collection; or if this BaseTorqueTurbinePermission has previously
528     * been saved, it will retrieve the related objects from storage.
529     *
530     * This method is protected by default in order to keep the public
531     * api reasonable.  You can change the access modifier to public
532     * by overriding this method in the child class.
533     */
534    protected List<TorqueTurbineRolePermission> getTorqueTurbineRolePermissionsJoinTorqueTurbineRole(Criteria criteria, Connection connection)
535        throws TorqueException
536    {
537        if (collTorqueTurbineRolePermissions == null)
538        {
539            if (isNew())
540            {
541                initTorqueTurbineRolePermissions();
542            }
543            else
544            {
545                criteria.and(org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermissionPeer.PERMISSION_ID, getEntityId());
546                collTorqueTurbineRolePermissions = org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermissionPeer.doSelectJoinTorqueTurbineRole(criteria, connection);
547                for (TorqueTurbineRolePermission torqueTurbineRolePermission : collTorqueTurbineRolePermissions)
548                {
549                    torqueTurbineRolePermission.setTorqueTurbinePermission((TorqueTurbinePermission) this);
550                }
551            }
552        }
553        else
554        {
555            // the following code is to determine if a new query is
556            // called for.  If the criteria is the same as the last
557            // one, just return the collection.
558            criteria.and(org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermissionPeer.PERMISSION_ID, getEntityId());
559            if (lastTorqueTurbineRolePermissionCriteria == null
560                        || !lastTorqueTurbineRolePermissionCriteria.equals(criteria))
561            {
562                collTorqueTurbineRolePermissions = org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermissionPeer.doSelectJoinTorqueTurbineRole(criteria, connection);
563                for (TorqueTurbineRolePermission torqueTurbineRolePermission : collTorqueTurbineRolePermissions)
564                {
565                    torqueTurbineRolePermission.setTorqueTurbinePermission((TorqueTurbinePermission) this);
566                }
567            }
568        }
569        lastTorqueTurbineRolePermissionCriteria = criteria;
570
571        return collTorqueTurbineRolePermissions;
572    }
573
574
575
576
577
578    /**
579     * Stores an object in the database.  If the object is new,
580     * it is inserted; otherwise an update is performed.
581     *
582     * @throws TorqueException if an error occurs during saving.
583     */
584    public void save() throws TorqueException
585    {
586        save(TorqueTurbinePermissionPeer.DATABASE_NAME);
587    }
588
589    /**
590     * Stores an object in the database.  If the object is new,
591     * it is inserted; otherwise an update is performed.
592     *
593     * @param dbName the name of the database to which the object
594     *        should be saved.
595     *
596     * @throws TorqueException if an error occurs during saving.
597     */
598    public void save(String dbName) 
599            throws TorqueException
600    {
601        try (TorqueConnection con = Transaction.begin(dbName))
602        {
603            save(con);
604            Transaction.commit(con);
605        }
606    }
607
608    /**
609     * Stores an object in the database.  If the object is new,
610     * it is inserted; otherwise an update is performed.  This method
611     * is meant to be used as part of a transaction, otherwise use
612     * the save() method and the connection details will be handled
613     * internally.
614     *
615     * @param con the connection to use for saving the object, not null.
616     *
617     * @throws TorqueException if an error occurs during saving.
618     */
619    public void save(Connection con) 
620            throws TorqueException
621    {
622        if (isSaving())
623        {
624            return;
625        }
626        try
627        {
628            setSaving(true);
629            // If this object has been modified, then save it to the database.
630            if (isModified())
631            {
632                if (isNew())
633                {
634                    TorqueTurbinePermissionPeer.doInsert((TorqueTurbinePermission) this, con);
635                    setNew(false);
636                }
637                else
638                {
639                    TorqueTurbinePermissionPeer.doUpdate((TorqueTurbinePermission) this, con);
640                }
641            }
642
643            if (isTorqueTurbineRolePermissionsInitialized())
644            {
645                for (TorqueTurbineRolePermission collTorqueTurbineRolePermissions : getTorqueTurbineRolePermissions())
646                {
647                    collTorqueTurbineRolePermissions.save(con);
648                }
649            }
650        }
651        finally
652        {
653            setSaving(false);
654        }
655    }
656
657
658
659
660    /**
661     * Set the PrimaryKey using ObjectKey.
662     *
663     * @param key entityId ObjectKey
664     */
665    public void setPrimaryKey(ObjectKey<?> key)
666        
667    {
668        setEntityId(Integer.valueOf(((NumberKey) key).intValue()));
669    }
670
671    /**
672     * Set the PrimaryKey using a String.
673     *
674     * @param key the primary key to set.
675     */
676    public void setPrimaryKey(String key) 
677    {
678        setEntityId(new Integer(key));
679    }
680
681
682    /**
683     * returns an id that differentiates this object from others
684     * of its class.
685     */
686    public ObjectKey<?> getPrimaryKey()
687    {
688        return SimpleKey.keyFor(getEntityId());
689    }
690
691
692
693    /**
694     * Makes a copy of this object.
695     * It creates a new object filling in the simple attributes.
696     * It then fills all the association collections and sets the
697     * related objects to isNew=true.
698     * @throws TorqueException if retrieval of the associated objects fails  
699     */
700    public TorqueTurbinePermission copy() throws TorqueException
701    {
702        return copy(true);
703    }
704
705    /**
706     * Makes a copy of this object using a connection.
707     * It creates a new object filling in the simple attributes.
708     * It then fills all the association collections and sets the
709     * related objects to isNew=true.
710     *
711     * @param con the database connection to read associated objects.
712     * @throws TorqueException if retrieval of the associated objects fails     
713     */
714    public TorqueTurbinePermission copy(Connection con) throws TorqueException
715    {
716        return copy(true, con);
717    }
718
719    /**
720     * Makes a copy of this object.
721     * It creates a new object filling in the simple attributes.
722     * If the parameter deepcopy is true, it then fills all the
723     * association collections and sets the related objects to
724     * isNew=true.
725     *
726     * @param deepcopy whether to copy the associated objects.
727     * @throws TorqueException if retrieval of the associated objects fails
728     */
729    public TorqueTurbinePermission copy(boolean deepcopy) throws TorqueException
730    {
731        TorqueTurbinePermission torqueTurbinePermission = new TorqueTurbinePermission();
732
733        return copyInto(torqueTurbinePermission, deepcopy);
734    }
735
736    /**
737     * Makes a copy of this object using connection.
738     * It creates a new object filling in the simple attributes.
739     * If the parameter deepcopy is true, it then fills all the
740     * association collections and sets the related objects to
741     * isNew=true.
742     *
743     * @param deepcopy whether to copy the associated objects.
744     * @param con the database connection to read associated objects.
745     * @throws TorqueException if retrieval of the associated objects fails
746     */
747    public TorqueTurbinePermission copy(boolean deepcopy, Connection con) throws TorqueException
748    {
749        TorqueTurbinePermission torqueTurbinePermission = new TorqueTurbinePermission();
750
751        return copyInto(torqueTurbinePermission, deepcopy, con);
752    }
753  
754    /**
755     * Fills the copyObj with the contents of this object.
756     * The associated objects are also copied and treated as new objects.
757     *
758     * @param copyObj the object to fill.
759     * @throws TorqueException if retrieval of the associated objects fails
760     */
761    public TorqueTurbinePermission copyInto(TorqueTurbinePermission copyObj) throws TorqueException
762    {
763        return copyInto(copyObj, true);
764    }
765
766    /**
767     * Fills the copyObj with the contents of this object using connection.
768     * The associated objects are also copied and treated as new objects.
769     *
770     * @param copyObj the object to fill.
771     * @param con the database connection to read associated objects.
772     * @throws TorqueException if retrieval of the associated objects fails
773     */
774    public TorqueTurbinePermission copyInto(TorqueTurbinePermission copyObj, Connection con) throws TorqueException
775    {
776        return copyInto(copyObj, true, con);
777    }
778  
779    /**
780     * Fills the copyObj with the contents of this object.
781     * If deepcopy is true, The associated objects are also copied
782     * and treated as new objects.
783     *
784     * @param copyObj the object to fill.
785     * @param deepcopy whether the associated objects should be copied.
786     * @throws TorqueException if retrieval of the associated objects fails
787     */
788    protected TorqueTurbinePermission copyInto(TorqueTurbinePermission copyObj, boolean deepcopy) throws TorqueException
789    {
790        copyObj.setEntityId((Integer) null);
791        copyObj.setEntityName(entityName);
792
793        if (deepcopy)
794        {
795            if (collTorqueTurbineRolePermissions != null)
796            {
797                for (TorqueTurbineRolePermission obj : collTorqueTurbineRolePermissions)
798                {
799                    copyObj.addTorqueTurbineRolePermission(obj.copy());
800                }
801            }
802            else
803            {
804                copyObj.collTorqueTurbineRolePermissions = null;
805            }
806        }
807        return copyObj;
808    }
809        
810    
811    /**
812     * Fills the copyObj with the contents of this object using connection.
813     * If deepcopy is true, The associated objects are also copied
814     * and treated as new objects.
815     *
816     * @param copyObj the object to fill.
817     * @param deepcopy whether the associated objects should be copied.
818     * @param con the database connection to read associated objects.
819     * @throws TorqueException if retrieval of the associated objects fails
820     */
821    public TorqueTurbinePermission copyInto(TorqueTurbinePermission copyObj, boolean deepcopy, Connection con) throws TorqueException
822    {
823        copyObj.setEntityId((Integer) null);
824        copyObj.setEntityName(entityName);
825
826        if (deepcopy)
827        {
828            for (TorqueTurbineRolePermission obj : getTorqueTurbineRolePermissions(con))
829            {
830                copyObj.addTorqueTurbineRolePermission(obj.copy());
831            }
832        }
833        return copyObj;
834    }
835
836    /** The Peer class */
837    private static final org.apache.fulcrum.security.torque.om.TorqueTurbinePermissionPeer peer
838            = new org.apache.fulcrum.security.torque.om.TorqueTurbinePermissionPeer();
839
840    /**
841     * returns a peer instance associated with this om.  Since Peer classes
842     * are not to have any instance attributes, this method returns the
843     * same instance for all member of this class. The method could therefore
844     * be static, but this would prevent one from overriding the behavior.
845     */
846    public org.apache.fulcrum.security.torque.om.TorqueTurbinePermissionPeer getPeer()
847    {
848        return peer;
849    }
850
851    /**
852     * Retrieves the TableMap object related to this Table data without
853     * compiler warnings of using getPeer().getTableMap().
854     *
855     * @return The associated TableMap object.
856     * @throws TorqueException if associated objects are not found
857     */
858    public TableMap getTableMap() throws TorqueException
859    {
860        return org.apache.fulcrum.security.torque.om.TorqueTurbinePermissionPeer.getTableMap();
861    }
862
863
864
865    public String toString()
866    {
867        StringBuffer str = new StringBuffer();
868        str.append("TorqueTurbinePermission:\n");
869        str.append("entityId = ")
870           .append(getEntityId())
871           .append("\n");
872        str.append("entityName = ")
873           .append(getEntityName())
874           .append("\n");
875        return(str.toString());
876    }
877
878    /**
879     * Compares the primary key of this instance with the key of another.
880     *
881     * @param toCompare The object to compare to.
882     * @return Whether the primary keys are equal and the object have the
883     *         same class.
884     */
885    public boolean equals(Object toCompare)
886    {
887        if (toCompare == null)
888        {
889            return false;
890        }
891        if (this == toCompare)
892        {
893            return true;
894        }
895        if (!getClass().equals(toCompare.getClass()))
896        {
897            return false;
898        }
899        TorqueTurbinePermission other = (TorqueTurbinePermission) toCompare;
900        if (getPrimaryKey() == null || other.getPrimaryKey() == null)
901        {
902            return false;
903        }
904        return getPrimaryKey().equals(other.getPrimaryKey());
905    }
906
907    /**
908     * If the primary key is not <code>null</code>, return the hashcode of the
909     * primary key.  Otherwise calls <code>Object.hashCode()</code>.
910     *
911     * @return an <code>int</code> value
912     */
913    public int hashCode()
914    {
915        ObjectKey<?> ok = getPrimaryKey();
916        if (ok == null)
917        {
918            return super.hashCode();
919        }
920
921        return ok.hashCode();
922    }
923
924
925
926    /**
927     * Compares the content of this object to another object
928     *
929     * @param toCompare The object to compare to.
930     * @return true if all of the columns in the other object have 
931     *         the same value as the objects in this class.
932     */
933    public boolean valueEquals(TorqueTurbinePermission toCompare)
934    {
935        if (toCompare == null)
936        {
937            return false;
938        }
939        if (this == toCompare)
940        {
941            return true;
942        }
943        if (!Objects.equals(this.entityId, toCompare.getEntityId()))
944        {
945            return false;
946        }
947        if (!Objects.equals(this.entityName, toCompare.getEntityName()))
948        {
949            return false;
950        }
951        return true;
952    }
953
954
955
956}