java.lang.Object
edu.internet2.middleware.grouper.ext.org.apache.ddlutils.io.DataToDatabaseSink
All Implemented Interfaces:
DataSink

public class DataToDatabaseSink extends Object implements DataSink
Data sink that directly inserts the beans into the database. If configured, it will make sure that the beans are inserted in the correct order according to the foreignkeys. Note that this will only work if there are no circles.
Version:
$Revision: 289996 $
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new sink instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addBean(org.apache.commons.beanutils.DynaBean bean)
    Adds a dyna bean.
    void
    end()
    Notifies the sink that all beans have been added.
    int
    Returns the (maximum) number of beans to insert in one batch.
    boolean
    Determines whether the sink delays the insertion of beans so that the beans referenced by it via foreignkeys are already inserted into the database.
    boolean
    Determines whether this sink halts when an error happens during the insertion of a bean into the database.
    boolean
    Determines whether batch mode is used for inserting the beans.
    void
    setBatchSize(int batchSize)
    Sets the (maximum) number of beans to insert in one batch.
    void
    setEnsureForeignKeyOrder(boolean ensureFkOrder)
    Specifies whether the sink shall delay the insertion of beans so that the beans referenced by it via foreignkeys are already inserted into the database.
    Note that you should careful with setting haltOnErrors to false as this might result in beans not inserted at all.
    void
    setHaltOnErrors(boolean haltOnErrors)
    Specifies whether this sink halts when an error happens during the insertion of a bean into the database.
    void
    setUseBatchMode(boolean useBatchMode)
    Specifies whether batch mode is used for inserting the beans.
    void
    Notifies the sink that beans will be added.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DataToDatabaseSink

      public DataToDatabaseSink(Platform platform, Database model)
      Creates a new sink instance.
      Parameters:
      platform - The database platform
      model - The database model
  • Method Details

    • isHaltOnErrors

      public boolean isHaltOnErrors()
      Determines whether this sink halts when an error happens during the insertion of a bean into the database. Default is true.
      Returns:
      true if the sink stops when an error occurred
    • setHaltOnErrors

      public void setHaltOnErrors(boolean haltOnErrors)
      Specifies whether this sink halts when an error happens during the insertion of a bean into the database.
      Parameters:
      haltOnErrors - true if the sink shall stop when an error occurred
    • isEnsureFkOrder

      public boolean isEnsureFkOrder()
      Determines whether the sink delays the insertion of beans so that the beans referenced by it via foreignkeys are already inserted into the database.
      Returns:
      true if beans are inserted after its foreignkey-references
    • setEnsureForeignKeyOrder

      public void setEnsureForeignKeyOrder(boolean ensureFkOrder)
      Specifies whether the sink shall delay the insertion of beans so that the beans referenced by it via foreignkeys are already inserted into the database.
      Note that you should careful with setting haltOnErrors to false as this might result in beans not inserted at all. The sink will then throw an appropriate exception at the end of the insertion process (method end()).
      Parameters:
      ensureFkOrder - true if beans shall be inserted after its foreignkey-references
    • isUseBatchMode

      public boolean isUseBatchMode()
      Determines whether batch mode is used for inserting the beans.
      Returns:
      true if batch mode is used (false per default)
    • setUseBatchMode

      public void setUseBatchMode(boolean useBatchMode)
      Specifies whether batch mode is used for inserting the beans. Note that this requires that the primary key values are not defined by the database.
      Parameters:
      useBatchMode - true if batch mode shall be used
    • getBatchSize

      public int getBatchSize()
      Returns the (maximum) number of beans to insert in one batch.
      Returns:
      The number of beans
    • setBatchSize

      public void setBatchSize(int batchSize)
      Sets the (maximum) number of beans to insert in one batch.
      Parameters:
      batchSize - The number of beans
    • end

      public void end() throws DataSinkException
      Notifies the sink that all beans have been added.
      Specified by:
      end in interface DataSink
      Throws:
      DataSinkException
    • start

      public void start() throws DataSinkException
      Notifies the sink that beans will be added.
      Specified by:
      start in interface DataSink
      Throws:
      DataSinkException
    • addBean

      public void addBean(org.apache.commons.beanutils.DynaBean bean) throws DataSinkException
      Adds a dyna bean.
      Specified by:
      addBean in interface DataSink
      Parameters:
      bean - The dyna bean to add
      Throws:
      DataSinkException