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()
PersistenceHandlerI
isForSaving
in interface PersistenceHandlerI
public void setAutoFinish(boolean b)
setAutoFinish
in interface PersistenceHandlerI
public void setIgnoreMultipleBegin()
setIgnoreMultipleBegin
in interface PersistenceHandlerI
public 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 PersistenceHandlerI
lockTimeout
- 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)
PersistenceHandlerI
This 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 PersistenceHandlerI
lockTimeout
- 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 PersistenceHandlerI
LockNotGrantedException
- 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 PersistenceHandlerI
public void cancelCreate(BO bo)
cancelCreate
in interface PersistenceHandlerI
public void purge(BO bo)
PersistenceHandlerI
This method schedules the specified BO for permanent deletion from the database.
purge
in interface PersistenceHandlerI
bo
- The BO to be purged.public void cancelPurge(BO bo)
PersistenceHandlerI
This 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 PersistenceHandlerI
bo
- The BO whose purge operation should be cancelled.public SchemaI getSchema()
getSchema
in interface PersistenceHandlerI
public void setBOType(BO bo)
public boolean exists(java.lang.Class<? extends BOI> classtip, java.lang.Long id)
exists
in interface PersistenceHandlerI
public boolean isLoadedReadOnly(java.lang.Long id)
PersistenceHandlerI
isLoadedReadOnly
in interface PersistenceHandlerI
public BO loadReadOnly(java.lang.Class<? extends BOI> classtip, java.lang.Long id)
loadReadOnly
in interface PersistenceHandlerI
public 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 PersistenceHandlerI
public BO assureClassStability(BO bo, int mode, java.util.Set<java.lang.Long> keepLocked)
assureClassStability
in interface PersistenceHandlerI
public 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 PersistenceHandlerI
public boolean isActive()
PersistenceHandlerI
isActive
in interface PersistenceHandlerI
public void rollback()
rollback
in interface PersistenceHandlerI
public void finish()
finish
in interface PersistenceHandlerI
public boolean isFinished()
PersistenceHandlerI
isFinished
in interface PersistenceHandlerI
public void commit()
PersistenceHandlerI
BOs
and persists changes to the database
storage; but is also called when data was just queried...?commit
in interface PersistenceHandlerI
public de.ipcon.db.core.QueryResultsI iterateQuery(java.lang.String s)
iterateQuery
in interface PersistenceHandlerI
public de.ipcon.db.core.QueryResultsI iterateQuery(java.lang.String s, java.lang.Object[] parms)
iterateQuery
in interface PersistenceHandlerI
public de.ipcon.db.core.QueryResultsI iterateQuery(java.lang.String s, java.lang.Object[] parms, short mode)
iterateQuery
in interface PersistenceHandlerI
public de.ipcon.db.core.QueryResultsI iterateNativeQuery(java.lang.String s)
iterateNativeQuery
in interface PersistenceHandlerI
public de.ipcon.db.core.QueryResultsI iterateNativeQuery(java.lang.String s, java.lang.Object[] parms)
iterateNativeQuery
in interface PersistenceHandlerI
public de.ipcon.db.core.QueryResultsI iterateNativeQuery(java.lang.String s, java.lang.Object[] parms, short mode)
iterateNativeQuery
in interface PersistenceHandlerI
public de.ipcon.db.core.QueryResultsI iterateNativeQuery(java.lang.String s, java.lang.Object[] parms, short mode, java.lang.String[] prefetchPaths)
iterateNativeQuery
in interface PersistenceHandlerI
public java.util.List listQuery(java.lang.String s)
listQuery
in interface PersistenceHandlerI
public java.util.List listQuery(java.lang.String s, java.lang.Object[] parms)
listQuery
in interface PersistenceHandlerI
public java.util.List listQuery(java.lang.String s, java.lang.Object[] parms, short mode)
listQuery
in interface PersistenceHandlerI
public 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 PersistenceHandlerI
public java.util.List listRelationBOs(java.lang.Class<? extends BOI> classtip, java.lang.Long id, java.lang.String attName, short mode)
listRelationBOs
in interface PersistenceHandlerI
public de.ipcon.db.core.QueryResultsI iterateRelationBOs(java.lang.Class classtip, java.lang.Long id, java.lang.String attName)
iterateRelationBOs
in interface PersistenceHandlerI
public de.ipcon.db.core.QueryResultsI iterateRelationBOs(java.lang.Class classtip, java.lang.Long id, java.lang.String attName, short mode)
iterateRelationBOs
in interface PersistenceHandlerI
public java.sql.Connection getJdbcConnection()
getJdbcConnection
in interface PersistenceHandlerI
public CastorPersistenceManager getManager()
public BOLoaderI getInjectBOLoader()
public void setInjectBOLoader(BOLoaderI $52)
setInjectBOLoader
in interface PersistenceHandlerI
public boolean isAutoFinish()
isAutoFinish
in interface PersistenceHandlerI
Copyright © 2000-2025 OAshi S.à r.l. All Rights Reserved.