net.sf.hajdbc.sync
Class FullSynchronizationStrategy

java.lang.Object
  extended by net.sf.hajdbc.sync.FullSynchronizationStrategy
All Implemented Interfaces:
SynchronizationStrategy

public class FullSynchronizationStrategy
extends Object
implements SynchronizationStrategy

Database-independent synchronization strategy that only updates differences between two databases. This strategy is best used when there are many differences between the active database and the inactive database (i.e. very much out of sync). The following algorithm is used:

  1. Drop the foreign keys on the inactive database (to avoid integrity constraint violations)
  2. For each database table:
    1. Delete all rows in the inactive database table
    2. Query all rows on the active database table
    3. For each row in active database table:
      1. Insert new row into inactive database table
  3. Re-create the foreign keys on the inactive database
  4. Synchronize sequences

Author:
Paul Ferraro

Constructor Summary
FullSynchronizationStrategy()
           
 
Method Summary
 int getFetchSize()
           
 int getMaxBatchSize()
           
 void setFetchSize(int fetchSize)
           
 void setMaxBatchSize(int maxBatchSize)
           
<D> void
synchronize(SynchronizationContext<D> context)
          Synchronizes a target database with a source database as defined by the synchronization context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FullSynchronizationStrategy

public FullSynchronizationStrategy()
Method Detail

synchronize

public <D> void synchronize(SynchronizationContext<D> context)
                 throws SQLException
Description copied from interface: SynchronizationStrategy
Synchronizes a target database with a source database as defined by the synchronization context.

Specified by:
synchronize in interface SynchronizationStrategy
Parameters:
context - a synchronization context
Throws:
SQLException - if synchronization fails
See Also:
SynchronizationStrategy.synchronize(net.sf.hajdbc.SynchronizationContext)

getFetchSize

public int getFetchSize()
Returns:
the fetchSize.

setFetchSize

public void setFetchSize(int fetchSize)
Parameters:
fetchSize - the fetchSize to set.

getMaxBatchSize

public int getMaxBatchSize()
Returns:
the maxBatchSize.

setMaxBatchSize

public void setMaxBatchSize(int maxBatchSize)
Parameters:
maxBatchSize - the maxBatchSize to set.