public class CastorPersistenceHandler extends java.lang.Object implements PersistenceHandlerI
This class wraps the Castor JDO `Database` object to address a specific bug in Windows related to PostgreSQL and IPC/file handling. Additionally, it enables centralized key creation by the `DBMan`, facilitating synchronization between MyTISM backends.
Key features:
DB_LOCKED, EXCLUSIVE, READ_ONLY, SHARED| Constructor and Description |
|---|
CastorPersistenceHandler(CastorPersistenceManager _pm,
org.exolab.castor.jdo.Database _db,
AbstractKeyGenerator _kg,
FulltextSearcherI _fts) |
CastorPersistenceHandler(CastorPersistenceManager _pm,
org.exolab.castor.jdo.Database _db,
AbstractKeyGenerator _kg,
FulltextSearcherI _fts,
boolean _forSaving) |
| Modifier and Type | Method and Description |
|---|---|
BO |
assureClassStability(BO bo,
int mode,
java.util.Set<java.lang.Long> keepLocked) |
BO |
assureClassStability(BO bo,
int mode,
java.util.Set<java.lang.Long> keepLocked,
int depth) |
BO |
assureClassStability(BO bo,
int mode,
java.util.Set<java.lang.Long> keepLocked,
int depth,
java.lang.String currAttr) |
BO |
assureClassStability(BO bo,
int mode,
java.util.Set<java.lang.Long> keepLocked,
int depth,
java.lang.String currAttr,
java.util.Map tempCache) |
void |
begin()
Initiates a new transaction within the persistence context.
|
void |
begin(int lockTimeout)
Initiates a new transaction within the persistence context.
|
void |
cancelCreate(BO bo) |
void |
cancelPurge(BO bo)
Cancels a previously scheduled purge operation for a BO.
|
void |
commit()
Actually creates new
BOs and persists changes to the database
storage; but is also called when data was just queried...? |
void |
complainSlowQuery(long lms,
java.lang.String s,
java.lang.Object[] parms) |
void |
create(BO bo) |
void |
dbLock(BO bo)
Checks if a db lock for the given
BO can be granted; does not actually do any locking! |
boolean |
exists(java.lang.Class<? extends BOI> classtip,
java.lang.Long id) |
void |
finish() |
BOLoaderI |
getInjectBOLoader()
_THE_ central query class as interfaced from MyTISM.
|
java.sql.Connection |
getJdbcConnection() |
CastorPersistenceManager |
getManager() |
SchemaI |
getSchema() |
boolean |
isActive()
Returns true if begin() was already called, false otherwise or if already finish()ed.
|
boolean |
isAutoFinish() |
boolean |
isFinished()
Returns true, if finish() was already called.
|
boolean |
isForSaving()
Returns true if the TransactionContext will remember all objects that were loaded with a readonly
lock.
|
boolean |
isLoadedReadOnly(java.lang.Long id)
Returns true if the BO with the passed id is currently loaded in read-only mode.
|
boolean |
isPersistent(BO bo) |
de.ipcon.db.core.QueryResultsI |
iterateNativeQuery(java.lang.String s) |
de.ipcon.db.core.QueryResultsI |
iterateNativeQuery(java.lang.String s,
java.lang.Object[] parms) |
de.ipcon.db.core.QueryResultsI |
iterateNativeQuery(java.lang.String s,
java.lang.Object[] parms,
short mode) |
de.ipcon.db.core.QueryResultsI |
iterateNativeQuery(java.lang.String s,
java.lang.Object[] parms,
short mode,
java.lang.String[] prefetchPaths) |
de.ipcon.db.core.QueryResultsI |
iterateQuery(java.lang.String s) |
de.ipcon.db.core.QueryResultsI |
iterateQuery(java.lang.String s,
java.lang.Object[] parms) |
de.ipcon.db.core.QueryResultsI |
iterateQuery(java.lang.String s,
java.lang.Object[] parms,
short mode) |
de.ipcon.db.core.QueryResultsI |
iterateRelationBOs(java.lang.Class classtip,
java.lang.Long id,
java.lang.String attName) |
de.ipcon.db.core.QueryResultsI |
iterateRelationBOs(java.lang.Class classtip,
java.lang.Long id,
java.lang.String attName,
short mode) |
java.util.List |
listQuery(java.lang.String s) |
java.util.List |
listQuery(java.lang.String s,
java.lang.Object[] parms) |
java.util.List |
listQuery(java.lang.String s,
java.lang.Object[] parms,
short mode) |
java.util.List |
listQuery(java.lang.String s,
java.lang.Object[] parms,
short mode,
boolean $native) |
java.util.List |
listRelationBOs(java.lang.Class<? extends BOI> classtip,
java.lang.Long id,
java.lang.String attName) |
java.util.List |
listRelationBOs(java.lang.Class<? extends BOI> classtip,
java.lang.Long id,
java.lang.String attName,
short mode) |
BO |
load(java.lang.Class<? extends BOI> classtip,
java.lang.Long id,
int mode,
java.util.Set<java.lang.Long> keepLocked,
BO into,
boolean syncModeCheck) |
BO |
loadReadOnly(java.lang.Class<? extends BOI> classtip,
java.lang.Long id) |
void |
purge(BO bo)
Marks a BO for purging from persistent storage upon transaction commit.
|
void |
resetRechash() |
void |
rollback() |
void |
setAutoFinish(boolean b) |
void |
setBOType(BO bo) |
void |
setIgnoreMultipleBegin() |
void |
setInjectBOLoader(BOLoaderI $52) |
public CastorPersistenceHandler(CastorPersistenceManager _pm, org.exolab.castor.jdo.Database _db, AbstractKeyGenerator _kg, FulltextSearcherI _fts)
public CastorPersistenceHandler(CastorPersistenceManager _pm, org.exolab.castor.jdo.Database _db, AbstractKeyGenerator _kg, FulltextSearcherI _fts, boolean _forSaving)
public boolean isForSaving()
PersistenceHandlerIisForSaving in interface PersistenceHandlerIpublic void setAutoFinish(boolean b)
setAutoFinish in interface PersistenceHandlerIpublic void setIgnoreMultipleBegin()
setIgnoreMultipleBegin in interface PersistenceHandlerIpublic void resetRechash()
public void begin()
This method begins a new transaction for interacting with the underlying persistence mechanism (e.g., a database).
If a transaction is already active, the existing transaction is reused.
If #setIgnoreMultipleBegin(boolean) was not called with true, an info about that is logged.
An `IllegalStateException` is thrown if the handler has already been finished.
If #isForSaving() is true, the transaction is started with a full read-only cache.
Otherwise, a standard transaction is initiated.
The method also handles potential exceptions related to locking and general persistence errors.
begin in interface PersistenceHandlerIlockTimeout - time to wait in seconds until a locking error is reported in case some
object is already locked by another thread; defaults to -1.
Zero or less for no waiting, i.e. immediate timeout (or rather the defined lock-timeout
of JDO, which defaults to 30s), an infinite value for no timeout.java.lang.IllegalStateException - If the handler has already been finished.LockNotGrantedException - If a lock cannot be acquired on the database.PersistenceException - If a general error occurs during the transaction initiation.public void begin(int lockTimeout)
PersistenceHandlerIThis method begins a new transaction for interacting with the underlying persistence mechanism (e.g., a database).
If a transaction is already active and #setIgnoreMultipleBegin(boolean) was called with true,
the existing transaction is reused. Otherwise the concrete implementation may decide what to do in that case.
An `IllegalStateException` is thrown if the handler has already been finished.
The method also handles potential exceptions related to locking and general persistence errors.
begin in interface PersistenceHandlerIlockTimeout - time to wait in seconds until a locking error is reported in case some
object is already locked by another thread; defaults to -1.
Zero or less for no waiting, i.e. immediate timeout (or rather the defined lock-timeout
of JDO, which defaults to 30s), an infinite value for no timeout.public void dbLock(BO bo)
BO can be granted; does not actually do any locking!dbLock in interface PersistenceHandlerILockNotGrantedException - if the check could not be performed or there is a reason for not being able
to grant the lockpublic void create(BO bo)
create in interface PersistenceHandlerIpublic void cancelCreate(BO bo)
cancelCreate in interface PersistenceHandlerIpublic void purge(BO bo)
PersistenceHandlerIThis method schedules the specified BO for permanent deletion from the database.
purge in interface PersistenceHandlerIbo - The BO to be purged.public void cancelPurge(BO bo)
PersistenceHandlerIThis method removes the specified BO from the internal collection of objects marked for deletion upon transaction commit. It is essential to ensure that the provided BO was indeed scheduled for purging before calling this method.
cancelPurge in interface PersistenceHandlerIbo - The BO whose purge operation should be cancelled.public SchemaI getSchema()
getSchema in interface PersistenceHandlerIpublic void setBOType(BO bo)
public boolean exists(java.lang.Class<? extends BOI> classtip, java.lang.Long id)
exists in interface PersistenceHandlerIpublic boolean isLoadedReadOnly(java.lang.Long id)
PersistenceHandlerIisLoadedReadOnly in interface PersistenceHandlerIpublic BO loadReadOnly(java.lang.Class<? extends BOI> classtip, java.lang.Long id)
loadReadOnly in interface PersistenceHandlerIpublic BO load(java.lang.Class<? extends BOI> classtip, java.lang.Long id, int mode, java.util.Set<java.lang.Long> keepLocked, BO into, boolean syncModeCheck)
load in interface PersistenceHandlerIpublic BO assureClassStability(BO bo, int mode, java.util.Set<java.lang.Long> keepLocked)
assureClassStability in interface PersistenceHandlerIpublic BO assureClassStability(BO bo, int mode, java.util.Set<java.lang.Long> keepLocked, int depth)
public BO assureClassStability(BO bo, int mode, java.util.Set<java.lang.Long> keepLocked, int depth, java.lang.String currAttr)
public BO assureClassStability(BO bo, int mode, java.util.Set<java.lang.Long> keepLocked, int depth, java.lang.String currAttr, java.util.Map tempCache)
public boolean isPersistent(BO bo)
isPersistent in interface PersistenceHandlerIpublic boolean isActive()
PersistenceHandlerIisActive in interface PersistenceHandlerIpublic void rollback()
rollback in interface PersistenceHandlerIpublic void finish()
finish in interface PersistenceHandlerIpublic boolean isFinished()
PersistenceHandlerIisFinished in interface PersistenceHandlerIpublic void commit()
PersistenceHandlerIBOs and persists changes to the database
storage; but is also called when data was just queried...?commit in interface PersistenceHandlerIpublic de.ipcon.db.core.QueryResultsI iterateQuery(java.lang.String s)
iterateQuery in interface PersistenceHandlerIpublic de.ipcon.db.core.QueryResultsI iterateQuery(java.lang.String s,
java.lang.Object[] parms)
iterateQuery in interface PersistenceHandlerIpublic de.ipcon.db.core.QueryResultsI iterateQuery(java.lang.String s,
java.lang.Object[] parms,
short mode)
iterateQuery in interface PersistenceHandlerIpublic de.ipcon.db.core.QueryResultsI iterateNativeQuery(java.lang.String s)
iterateNativeQuery in interface PersistenceHandlerIpublic de.ipcon.db.core.QueryResultsI iterateNativeQuery(java.lang.String s,
java.lang.Object[] parms)
iterateNativeQuery in interface PersistenceHandlerIpublic de.ipcon.db.core.QueryResultsI iterateNativeQuery(java.lang.String s,
java.lang.Object[] parms,
short mode)
iterateNativeQuery in interface PersistenceHandlerIpublic de.ipcon.db.core.QueryResultsI iterateNativeQuery(java.lang.String s,
java.lang.Object[] parms,
short mode,
java.lang.String[] prefetchPaths)
iterateNativeQuery in interface PersistenceHandlerIpublic java.util.List listQuery(java.lang.String s)
listQuery in interface PersistenceHandlerIpublic java.util.List listQuery(java.lang.String s,
java.lang.Object[] parms)
listQuery in interface PersistenceHandlerIpublic java.util.List listQuery(java.lang.String s,
java.lang.Object[] parms,
short mode)
listQuery in interface PersistenceHandlerIpublic java.util.List listQuery(java.lang.String s,
java.lang.Object[] parms,
short mode,
boolean $native)
public void complainSlowQuery(long lms,
java.lang.String s,
java.lang.Object[] parms)
public java.util.List listRelationBOs(java.lang.Class<? extends BOI> classtip, java.lang.Long id, java.lang.String attName)
listRelationBOs in interface PersistenceHandlerIpublic java.util.List listRelationBOs(java.lang.Class<? extends BOI> classtip, java.lang.Long id, java.lang.String attName, short mode)
listRelationBOs in interface PersistenceHandlerIpublic de.ipcon.db.core.QueryResultsI iterateRelationBOs(java.lang.Class classtip,
java.lang.Long id,
java.lang.String attName)
iterateRelationBOs in interface PersistenceHandlerIpublic de.ipcon.db.core.QueryResultsI iterateRelationBOs(java.lang.Class classtip,
java.lang.Long id,
java.lang.String attName,
short mode)
iterateRelationBOs in interface PersistenceHandlerIpublic java.sql.Connection getJdbcConnection()
getJdbcConnection in interface PersistenceHandlerIpublic CastorPersistenceManager getManager()
public BOLoaderI getInjectBOLoader()
public void setInjectBOLoader(BOLoaderI $52)
setInjectBOLoader in interface PersistenceHandlerIpublic boolean isAutoFinish()
isAutoFinish in interface PersistenceHandlerICopyright © 2000-2025 OAshi S.à r.l. All Rights Reserved.