com.objectwave.persist.broker
Class SaveObjectsStrategy

java.lang.Object
  |
  +--com.objectwave.persist.broker.SaveObjectsStrategy

public class SaveObjectsStrategy
extends java.lang.Object

Figure out the order that the persistent objects should be saved.

Version:
$Id: SaveObjectsStrategy.java,v 1.1 2001/07/05 13:22:55 dave_hoag Exp $
Author:
dhoag

Constructor Summary
SaveObjectsStrategy()
          Constructor for the SaveObjectsStrategy object
 
Method Summary
 boolean contains(java.lang.Object obj, java.util.List aList)
          Do an identity compare to determine if the List contains the object.
 RDBPersistence getRDBAdapter(Persistence object)
          A utility method that simplifies code.
 void saveObjects(java.util.ArrayList objs)
          Save all of the objects in the objs collection.
protected  int saveObjects(java.util.List objs, java.util.ArrayList undoList, int sizeOfLaterList, int depth)
          We may have several objects to save.
protected  boolean unsavedForeignKeys(AttributeTypeColumn[] fkColumns, Persistence sourceObj)
          Determines if in the collection of persistent objects if there exists an object that is neither transient nor 'saved'/persistent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SaveObjectsStrategy

public SaveObjectsStrategy()
Constructor for the SaveObjectsStrategy object

Method Detail

getRDBAdapter

public final RDBPersistence getRDBAdapter(Persistence object)
A utility method that simplifies code.

Parameters:
object -
Returns:
The RDBAdapter value

saveObjects

public void saveObjects(java.util.ArrayList objs)
                 throws QueryException
Save all of the objects in the objs collection. This will attempt to save objects in an order that makes sense to a relational database.

Parameters:
objs - The peristent objects to save.
Throws:
QueryException

contains

public boolean contains(java.lang.Object obj,
                        java.util.List aList)
Do an identity compare to determine if the List contains the object. Created because most Lists do an 'equals' comparison, not an identity compare.

Parameters:
obj - java.lang.Object The object for which we are looking
aList - The list being searched.
Returns:
boolean true if the object is in the provided list.

saveObjects

protected int saveObjects(java.util.List objs,
                          java.util.ArrayList undoList,
                          int sizeOfLaterList,
                          int depth)
                   throws QueryException
We may have several objects to save. This attempts to save them in some 'order' that makes sense for a relational database.

Parameters:
objs - The peristent objects to save. This list should shrink with every recursive call
undoList - Those new objects that have been inserted into the database will be added to this list.
sizeOfLaterList -
depth -
Returns:
Throws:
QueryException
See Also:
#save

unsavedForeignKeys

protected boolean unsavedForeignKeys(AttributeTypeColumn[] fkColumns,
                                     Persistence sourceObj)
Determines if in the collection of persistent objects if there exists an object that is neither transient nor 'saved'/persistent.

Parameters:
fkColumns -
sourceObj -
Returns:
boolean true if there are unsaved foreign keys in the list of data.