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 typeID- 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
FieldsFields inherited from class me.confuser.banmanager.common.ormlite.dao.BaseDaoImpl
connectionSource, databaseType, dataClass, lastIterator, objectFactory, statementExecutor, tableConfig, tableInfo -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseStorage(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 TypeMethodDescriptionintCreates an entity with database-authoritative timestamps.intcreatePreservingTimestamps(T data) Creates an entity preserving its Java-side timestamps.protected Stringprotected DatabaseConfigprotected booleanintUpdates an entity and sets the 'updated' column to database time.intupdatePreservingTimestamps(T data) 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, updateRawMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
plugin
-
-
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
- 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
- Returns:
- the DatabaseConfig for this storage (localDb or globalDb)
-
create
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:
createin interfaceme.confuser.banmanager.common.ormlite.dao.Dao<T,ID> - Overrides:
createin classme.confuser.banmanager.common.ormlite.dao.BaseDaoImpl<T,ID> - Throws:
SQLException
-
createPreservingTimestamps
Creates an entity preserving its Java-side timestamps. Use this for imports where you want to keep the original timestamp values.- Throws:
SQLException
-
update
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:
updatein interfaceme.confuser.banmanager.common.ormlite.dao.Dao<T,ID> - Overrides:
updatein classme.confuser.banmanager.common.ormlite.dao.BaseDaoImpl<T,ID> - Throws:
SQLException
-
updatePreservingTimestamps
Updates an entity preserving its Java-side timestamps. Use this when you want to keep the existing timestamp values.- Throws:
SQLException
-