Class EntityConnections


  • public final class EntityConnections
    extends Object
    A static helper class for mass data manipulation.
    • Method Detail

      • copyEntities

        public static void copyEntities​(EntityConnection source,
                                        EntityConnection destination,
                                        int batchSize,
                                        boolean includePrimaryKeys,
                                        String... entityIds)
                                 throws DatabaseException
        Copies the given entities from source to destination
        Parameters:
        source - the source db
        destination - the destination db
        batchSize - the number of records to copy between commits
        includePrimaryKeys - if true primary key values are included, if false then they are assumed to be auto-generated
        entityIds - the IDs of the entity types to copy
        Throws:
        DatabaseException - in case of a db exception
        IllegalArgumentException - if batchSize is not a positive integer
      • batchInsert

        public static List<Entity.Key> batchInsert​(EntityConnection connection,
                                                   List<Entity> entities,
                                                   int batchSize,
                                                   EventDataListener<Integer> progressReporter)
                                            throws DatabaseException
        Inserts the given entities, performing a commit after each batchSize number of inserts.
        Parameters:
        connection - the entity connection to use when inserting
        entities - the entities to insert
        batchSize - the commit batch size
        progressReporter - if specified this will be used to report batch progress
        Returns:
        the primary keys of successfully inserted entities
        Throws:
        DatabaseException - in case of an exception
        IllegalArgumentException - if batchSize is not a positive integer