Class JDBCRowMapper

    • Field Detail

      • COLLECTION_DELETE_BEFORE_APPEND_PROP

        public static final String COLLECTION_DELETE_BEFORE_APPEND_PROP
        Property to determine whether collection appends delete all then re-insert, or are optimized for append.
        See Also:
        Constant Field Values
    • Method Detail

      • receiveInvalidations

        public VCSInvalidations receiveInvalidations()
        Description copied from interface: RowMapper
        Processes and returns the invalidations queued for processing by the cache (if any).

        Called pre-transaction by session start or transactionless save;

        Specified by:
        receiveInvalidations in interface RowMapper
        Returns:
        the invalidations, or null
      • sendInvalidations

        public void sendInvalidations​(VCSInvalidations invalidations)
        Description copied from interface: RowMapper
        Post-transaction invalidations notification.

        Called post-transaction by session commit/rollback or transactionless save.

        Specified by:
        sendInvalidations in interface RowMapper
        Parameters:
        invalidations - the known invalidations to send to others, or null
      • clearCache

        public void clearCache()
        Description copied from interface: RowMapper
        Clears the mapper's cache (if any)

        Called after a rollback, or a manual clear through RepositoryStatus MBean.

        Specified by:
        clearCache in interface RowMapper
      • getCacheSize

        public long getCacheSize()
        Description copied from interface: RowMapper
        Evaluate the cached elements size
        Specified by:
        getCacheSize in interface RowMapper
      • rollback

        public void rollback()
        Description copied from interface: RowMapper
        Rollback the transaction.

        This is in the RowMapper interface because on rollback the cache must be invalidated.

        Specified by:
        rollback in interface RowMapper
      • read

        public List<? extends RowId> read​(Collection<RowId> rowIds,
                                          boolean cacheOnly)
        Description copied from interface: RowMapper
        Reads a set of rows for the given RowIds.

        For each requested row, either a Row is found and returned, or a RowId (not implementing Row) is returned to signify an absent row.

        Specified by:
        read in interface RowMapper
        Parameters:
        rowIds - the row ids (including their table name)
        cacheOnly - if true, only hit memory
        Returns:
        the collection of Rows (or RowIds if the row was absent from the database). Order is not the same as the input rowIds
      • readSimpleRows

        protected List<Row> readSimpleRows​(String tableName,
                                           Collection<Serializable> ids)
        Gets a list of rows for SimpleFragments from the database, given the table name and the ids.
        Parameters:
        tableName - the table name
        ids - the ids
        Returns:
        the list of rows, without the missing ones
      • readCollectionArrays

        protected List<Row> readCollectionArrays​(String tableName,
                                                 Collection<Serializable> ids)
        Reads several collection rows, given a table name and the ids.
        Parameters:
        tableName - the table name
        ids - the ids
      • write

        public void write​(RowMapper.RowBatch batch)
        Description copied from interface: RowMapper
        Writes a set of rows. This includes creating, updating and deleting rows.
        Specified by:
        write in interface RowMapper
        Parameters:
        batch - the set of rows and the operations to do on them
      • writeCreates

        protected void writeCreates​(List<Row> creates)
      • writeDeletes

        protected void writeDeletes​(Collection<RowId> deletes)
      • insertSimpleRows

        protected void insertSimpleRows​(String tableName,
                                        List<Row> rows)
        Inserts multiple rows, all for the same table.
      • insertCollectionRows

        protected void insertCollectionRows​(String tableName,
                                            List<RowMapper.RowUpdate> rowus)
        Updates multiple collection rows, all for the same table.
      • updateSimpleRows

        protected void updateSimpleRows​(String tableName,
                                        List<RowMapper.RowUpdate> rows)
        Updates multiple simple rows, all for the same table.
      • deleteRows

        protected void deleteRows​(String tableName,
                                  Set<Serializable> ids)
        Deletes multiple rows, all for the same table.
      • cleanupDeletedRows

        public int cleanupDeletedRows​(int max,
                                      Calendar beforeTime)
        Clean up soft-deleted rows.

        Rows deleted more recently than the beforeTime are left alone. Only a limited number of rows may be deleted, to prevent transaction during too long.

        Parameters:
        max - the maximum number of rows to delete at a time
        beforeTime - the maximum deletion time of the rows to delete
        Returns:
        the number of rows deleted
      • readSimpleRow

        public Row readSimpleRow​(RowId rowId)
        Description copied from interface: RowMapper
        Gets a row for a SimpleFragment from the database, given its table name and id. If the row doesn't exist, null is returned.
        Specified by:
        readSimpleRow in interface RowMapper
        Parameters:
        rowId - the row id
        Returns:
        the row, or null
      • getBinaryFulltext

        public Map<String,​String> getBinaryFulltext​(RowId rowId)
        Description copied from interface: RowMapper
        Gets the fulltext extracted from the binary fields.
        Specified by:
        getBinaryFulltext in interface RowMapper
        Parameters:
        rowId - the row id
        Returns:
        the fulltext string representation or null if unsupported
      • readCollectionRowArray

        public Serializable[] readCollectionRowArray​(RowId rowId)
        Description copied from interface: RowMapper
        Gets an array for a CollectionFragment from the database, given its table name and id. If no rows are found, an empty array is returned.
        Specified by:
        readCollectionRowArray in interface RowMapper
        Parameters:
        rowId - the row id
        Returns:
        the array
      • readSelectionRows

        public List<Row> readSelectionRows​(SelectionType selType,
                                           Serializable selId,
                                           Serializable filter,
                                           Serializable criterion,
                                           boolean limitToOne)
        Description copied from interface: RowMapper
        Reads the rows corresponding to a selection.
        Specified by:
        readSelectionRows in interface RowMapper
        Parameters:
        selType - the selection type
        selId - the selection id (parent id for a hierarchy selection)
        filter - the filter value (name for a hierarchy selection)
        criterion - an optional additional criterion depending on the selection type (complex prop flag for a hierarchy selection)
        limitToOne - whether to stop after one row retrieved
        Returns:
        the list of rows
      • copy

        public RowMapper.CopyResult copy​(RowMapper.IdWithTypes source,
                                         Serializable destParentId,
                                         String destName,
                                         Row overwriteRow,
                                         boolean excludeSpecialChildren,
                                         boolean excludeACL)
        Description copied from interface: RowMapper
        Copies the hierarchy starting from a given row to a new parent with a new name.

        If the new parent is null, then this is a version creation, which doesn't recurse in regular children.

        If overwriteRow is passed, the copy is done onto this existing node as its root (version restore) instead of creating a new node in the parent.

        Specified by:
        copy in interface RowMapper
        Parameters:
        source - the id, primary type and mixin types of the row to copy
        destParentId - the new parent id, or null
        destName - the new name
        overwriteRow - when not null, the copy is done onto this existing row, and the values are set in hierarchy
        excludeSpecialChildren - the flag to exclude special children from copy
        excludeACL - the flag to exclude ACL from copy
        Returns:
        info about the copy
      • updateSimpleRowWithValues

        protected void updateSimpleRowWithValues​(String tableName,
                                                 Row row)
        Updates a row in the database with given explicit values.
      • copyHierRecursive

        protected Serializable copyHierRecursive​(RowMapper.IdWithTypes source,
                                                 Serializable parentId,
                                                 String name,
                                                 Serializable overwriteId,
                                                 boolean resetVersion,
                                                 Map<Serializable,​Serializable> idMap,
                                                 Map<Serializable,​RowMapper.IdWithTypes> idToTypes,
                                                 Set<Serializable> recordIds,
                                                 boolean excludeSpecialChildren)
                                          throws SQLException
        Copies hierarchy from id to parentId, and recurses.

        If name is null, then the original name is kept.

        idMap is filled with info about the correspondence between original and copied ids. idToTypes is filled with the type of each (source) fragment. recordIds is filled with the copied ids of documents that used to be records.

        TODO: this should be optimized to use a stored procedure.

        Parameters:
        overwriteId - when not null, the copy is done onto this existing node (skipped)
        Returns:
        the new root id
        Throws:
        SQLException
      • remove

        public void remove​(Serializable rootId,
                           List<RowMapper.NodeInfo> nodeInfos)
        Description copied from interface: RowMapper
        Deletes a hierarchy.
        Specified by:
        remove in interface RowMapper
        Parameters:
        rootId - the id of the root node to be deleted with its children
        nodeInfos - the information about all descendants being deleted along the root node
      • getDescendantsInfo

        public List<RowMapper.NodeInfo> getDescendantsInfo​(Serializable rootId)
        Description copied from interface: RowMapper
        Gets descendants infos from a given root node. This does not include information about the root node itself.
        Specified by:
        getDescendantsInfo in interface RowMapper
        Parameters:
        rootId - the root node id from which to get descendants info
        Returns:
        the list of descendant nodes info