Class BaseStorage<T,ID>

java.lang.Object
me.confuser.banmanager.common.ormlite.dao.BaseDaoImpl<T,ID>
me.confuser.banmanager.common.storage.BaseStorage<T,ID>
Type Parameters:
T - the entity type
ID - the ID type
All Implemented Interfaces:
Iterable<T>, me.confuser.banmanager.common.ormlite.dao.CloseableIterable<T>, me.confuser.banmanager.common.ormlite.dao.Dao<T,ID>
Direct Known Subclasses:
GlobalIpBanRecordStorage, GlobalIpBanStorage, GlobalPlayerBanRecordStorage, GlobalPlayerBanStorage, GlobalPlayerMuteRecordStorage, GlobalPlayerMuteStorage, GlobalPlayerNoteStorage, IpBanRecordStorage, IpBanStorage, IpMuteRecordStorage, IpMuteStorage, IpRangeBanRecordStorage, IpRangeBanStorage, NameBanRecordStorage, NameBanStorage, PlayerBanRecordStorage, PlayerBanStorage, PlayerKickStorage, PlayerMuteRecordStorage, PlayerMuteStorage, PlayerNoteStorage, PlayerReportStorage, PlayerWarnStorage, RollbackStorage

public abstract class BaseStorage<T,ID> extends me.confuser.banmanager.common.ormlite.dao.BaseDaoImpl<T,ID>
Base storage class for BanManager that provides database-authoritative timestamps. All storage classes that need cross-server sync should extend this instead of BaseDaoImpl.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface me.confuser.banmanager.common.ormlite.dao.Dao

    me.confuser.banmanager.common.ormlite.dao.Dao.CreateOrUpdateStatus, me.confuser.banmanager.common.ormlite.dao.Dao.DaoObserver
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final BanManagerPlugin
     

    Fields inherited from class me.confuser.banmanager.common.ormlite.dao.BaseDaoImpl

    connectionSource, databaseType, dataClass, lastIterator, objectFactory, statementExecutor, tableConfig, tableInfo
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    BaseStorage(BanManagerPlugin plugin, me.confuser.banmanager.common.ormlite.support.ConnectionSource connectionSource, me.confuser.banmanager.common.ormlite.table.DatabaseTableConfig<T> tableConfig, DatabaseConfig dbConfig)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    create(T data)
    Creates an entity with database-authoritative timestamps.
    int
    Creates an entity preserving its Java-side timestamps.
    protected String
     
    protected DatabaseConfig
     
    protected boolean
     
    int
    update(T data)
    Updates an entity and sets the 'updated' column to database time.
    int
    Updates an entity preserving its Java-side timestamps.

    Methods inherited from class me.confuser.banmanager.common.ormlite.dao.BaseDaoImpl

    assignEmptyForeignCollection, callBatchTasks, checkForInitialized, clearAllInternalObjectCaches, clearObjectCache, closeableIterator, closeLastIterator, commit, countOf, countOf, create, createIfNotExists, createOrUpdate, delete, delete, delete, deleteBuilder, deleteById, deleteIds, endThreadConnection, executeRaw, executeRawNoArgs, extractId, findForeignFieldType, getConnectionSource, getDataClass, getEmptyForeignCollection, getObjectCache, getObjectFactory, getRawRowMapper, getSelectStarRowMapper, getTableConfig, getTableInfo, getTableName, getWrappedIterable, getWrappedIterable, idExists, initialize, isAutoCommit, isTableExists, isUpdatable, iterator, iterator, iterator, iterator, mapSelectStarRow, notifyChanges, objectsEqual, objectToString, query, queryBuilder, queryForAll, queryForEq, queryForFieldValues, queryForFieldValuesArgs, queryForFirst, queryForId, queryForMatching, queryForMatchingArgs, queryForSameId, queryRaw, queryRaw, queryRaw, queryRaw, queryRaw, queryRawValue, refresh, registerObserver, rollBack, setAutoCommit, setConnectionSource, setObjectCache, setObjectCache, setObjectFactory, setTableConfig, startThreadConnection, unregisterObserver, update, updateBuilder, updateId, updateRaw

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Field Details

  • Constructor Details

    • BaseStorage

      protected BaseStorage(BanManagerPlugin plugin, me.confuser.banmanager.common.ormlite.support.ConnectionSource connectionSource, me.confuser.banmanager.common.ormlite.table.DatabaseTableConfig<T> tableConfig, DatabaseConfig dbConfig) throws SQLException
      Throws:
      SQLException
  • Method Details

    • getBmTableName

      protected String getBmTableName()
      Returns:
      the table name for this storage (for timestamp updates)
    • hasUpdatedColumn

      protected boolean hasUpdatedColumn()
      Returns:
      true if this entity has an 'updated' column, false if only 'created' Defaults to true; override and return false for entities with only 'created'
    • getDatabaseConfig

      protected DatabaseConfig getDatabaseConfig()
      Returns:
      the DatabaseConfig for this storage (localDb or globalDb)
    • create

      public int create(T data) throws SQLException
      Creates an entity with database-authoritative timestamps. After inserting, updates created/updated to UNIX_TIMESTAMP() and refreshes the entity. This ensures cross-server sync works correctly regardless of JVM clock drift.
      Specified by:
      create in interface me.confuser.banmanager.common.ormlite.dao.Dao<T,ID>
      Overrides:
      create in class me.confuser.banmanager.common.ormlite.dao.BaseDaoImpl<T,ID>
      Throws:
      SQLException
    • createPreservingTimestamps

      public int createPreservingTimestamps(T data) throws SQLException
      Creates an entity preserving its Java-side timestamps. Use this for imports where you want to keep the original timestamp values.
      Throws:
      SQLException
    • update

      public int update(T data) throws SQLException
      Updates an entity and sets the 'updated' column to database time. This ensures cross-server sync works correctly regardless of JVM clock drift.
      Specified by:
      update in interface me.confuser.banmanager.common.ormlite.dao.Dao<T,ID>
      Overrides:
      update in class me.confuser.banmanager.common.ormlite.dao.BaseDaoImpl<T,ID>
      Throws:
      SQLException
    • updatePreservingTimestamps

      public int updatePreservingTimestamps(T data) throws SQLException
      Updates an entity preserving its Java-side timestamps. Use this when you want to keep the existing timestamp values.
      Throws:
      SQLException