Class FastAnnotationLoader<T>

java.lang.Object
net.sf.basedb.core.FastAnnotationLoader<T>
Type Parameters:
T - The type of values for the annotation

public class FastAnnotationLoader<T> extends Object
Implements an API for simple and fast loading of annotation values optimized for situations when a single annotation is needed for many (=thousands) of items. The regular annotation API is typically very slow and requires multiple SQL queries for each annotation. The SnapshotManager API is typically faster, but only if the annotations have already been cached. This API have limited filtering capabilities and can be used for reading only, but it can be combined with the AnnotationBatcher API for updating annotations. The result is returned as an iterator with each entry corresponding to a single annotation value. The values are not sorted in any particular order. If the annotation type allows multiple values each value is returned as separate iterator entries in no particular order. If the annotation type supports project-specific values, only default values and values for the current project are returned.
Since:
3.19.10
See Also:
  • Field Details

    • dc

      private final DbControl dc
    • type

      private final AnnotationType type
    • projectId

      private int projectId
    • includeDefault

      private boolean includeDefault
  • Constructor Details

  • Method Details

    • setProject

      public void setProject(Project p)
      If the annotation type supports project-specific annotations this method can be used to control which values that are loaded. The default setting is to load default values and values for the currently active project.
      Parameters:
      p - The project that values should belong to, or null to not load any project-specific values
    • setIncludeDefault

      public void setIncludeDefault(boolean includeDefault)
      If the annotation type supports project-specific annotations this method can be used to control which values that are loaded. The default setting is to load default values and values for the currently active project.
      Parameters:
      includeDefault - TRUE to include default values, FALSE to not include them
    • load

      Load the annotation values for all items returned by the query. This method is typically faster than the load(Collection) method since the AbstractEntityQuery.idList(DbControl) is used to only load item ids and not full items.
    • load

      Load the annotation values for all items in the given collection. Note! All items in the collection must be of the same type.
    • load

      Load the annotation values for all items returned by the given iterator. Note! All items returned by the iterator must be of the same type.