|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jsdai.lang.SdaiCommon jsdai.lang.SdaiTransaction
Transactions control operations performed during the session.
JSDAI conforms to transaction level 3, see
"ISO 10303-22::13.1.1 Levels of transaction" for its definition.
Therefore, an application always has to start either a read-only or read-write
transaction before the contents of any SdaiModel
is accessed.
When a transaction is committed, the data which were changed are written
to the binary files in the appropriate directories. In the case when
a transaction is aborted, the previous state of all open
SdaiRepositories
with SdaiModel
s and their instances
inside them is restored. Entity instances created after the most recent
start transaction with read-write access or commit operation performed
become invalid.
For details please look at "ISO 10303-22::7.4.5 sdai_transaction".
Last update 2006-01-25
SdaiTransactions
have some differences from SDAI transactions in ISO 10303-22
when used with remote JSDAI-DB repositories. The reason for this is multiuser
user concurrent environment and underlying RDBMS specifics.
SdaiSession.createRepository(java.lang.String, java.lang.Object)
, SdaiSession.importClearTextEncoding(java.lang.String, java.lang.Object, java.lang.Object)
SdaiRepository.openRepository()
, and SdaiRepository.closeRepository()
.
This is related to the fact that all changes in RDBMS are transaction oriented. For backward
compatibility if transaction is not running while the above methods are invoked the appropriate
transaction is started and committed afterwards.SdaiTransaction
methods commit()
and abort()
implies
starting a new SDAI transaction associated with the same SdaiTransaction
object.
Also open remote repository contents are reloaded to reflect the status at the moment
new transaction started. This includes aggregates of SdaiModels
and
SchemaInstances
, associated models of SchemaInstances
and
entity instances and their values of SdaiModels
that have their accesses started.
JSDAI guarantees that SdaiModel
, SchemaInstance
and EEntity
object instances are retained as long as they point to existing
object on the database throughout the lifetime of active SdaiTransaction
.
Aggregate and ExternalData
objects may become invalid after commit
and abort
operation.SdaiTransaction
methods endTransactionAccessCommit()
and
endTransactionAccessAbort()
end active transaction. Starting new SdaiTransaction
afterwards does not ensure that open repositories reflect actual status on JSDAI-DB. However
opening the repository with this new transaction following closing it will force refreshing
the repositorySdaiTransaction
methods commit()
and endTransactionAccessCommit()
may fail if any of SdaiModels
or SchemaInstances
modified during
the transaction was concurrently changed by another SdaiSession
. If this
situation occurs the commit operation fails with jsdai.client.SdaiExceptionRemote
.
Application can only abort transaction afterwards.commit
or
abort
operation is locked from changing within the commit
and
endTransactionAccessCommit
operation for the moment changes are written
to JSDAI-DB.The above mentioned remote SdaiTransaction
specifics ensure data consistency even
when many users are making changes on JSDAI-DB.
Bellow are the examples of some situations that may occur when several users are making simultaneous changes to JSDAI-DB:
Suppose there are two SdaiModels
A and B. There are two users working on JSDAI-DB
user1
and user2
. Model A has entity instance #1
and model
B has instances #2
and #3
. Attribute #1.a1
has string
value 'id1'
and attribute #1.a2
has entity reference
value #2
.
user1
starts new transaction and starts R/W access for model Auser2
starts new transaction and starts R/W access for model Auser1
changes #1.a1
to 'id2'
user2
changes #1.a1
to 'id2'
user1
commits active transaction. Commit operation succeedsuser2
commits active transaction. Commit operation failsuser2
aborts active transactionuser2
gets value of #1.a1
which is
'id2'
nowuser2
changes #1.a1
to 'id3'
user2
commits active transaction. Commit operation succeedsuser1
starts new transaction and starts R/W access for model Auser2
starts new transaction and starts R/W access for model Buser1
creates new instance #4
and assigns
'id2'
to #4.a1
user2
creates new instance #5
and assigns
'id2'
to #5.a1
user1
commits active transaction. Commit operation succeedsuser2
commits active transaction. Commit operation failsuser2
aborts active transactionuser2
detects that #4
with #4.a1
value
'id2'
was createduser2
creates new instance #6
and assigns
'id3'
to #6.a1
user2
commits active transaction. Commit operation succeedsuser1
starts new transaction and starts access R/W for model A
and R/O for model Buser2
starts new transaction and starts access R/W for model Buser1
changes #1.a2
to #3
user2
deletes instance #3
user1
commits active transaction. Commit operation succeedsuser2
commits active transaction. Commit operation succeedsuser1
aborts active transactionuser1
detects that #1.a2
value is unset
Field Summary | |
static int |
NO_ACCESS
When getMode returns this value, all operations for accessing
entity instances within session are disallowed. |
static int |
READ_ONLY
When getMode returns this value, entity instances within session
are or may become available (after starting access to owning model) for read-only access. |
static int |
READ_WRITE
When getMode returns this value, entity instances within session
are or may become available (after starting access to owning model) for read-write access. |
Method Summary | |
void |
abort()
Restores the state of all open repositories, which existed at the time when the most recent start transaction with read-write access or commit operation was performed. |
void |
commit()
Makes persistent all changes in all open repositories made since the most recent either start transaction with read-write access, commit, or abort operation was performed. |
void |
commit(java.lang.String appComment)
Makes persistent all changes in all open repositories made since the most recent either start transaction with read-write access, commit, or abort operation was performed. |
void |
endTransactionAccessAbort()
Ends the sequence of operations started by startTransactionReadWriteAccess or startTransactionReadOnlyAccess method. |
void |
endTransactionAccessCommit()
Ends the sequence of operations started by startTransactionReadWriteAccess or startTransactionReadOnlyAccess method. |
void |
endTransactionAccessCommit(java.lang.String appComment)
Ends the sequence of operations started by startTransactionReadWriteAccess or startTransactionReadOnlyAccess method. |
int |
getMode()
Returns the current access mode provided by this SdaiTransaction
within SdaiSession .
|
SdaiSession |
getOwningSession()
Returns the only one SdaiSession object. |
java.lang.String |
toString()
Returns a description of this transaction as a String .
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int NO_ACCESS
getMode
returns this value, all operations for accessing
entity instances within session are disallowed.
public static final int READ_ONLY
getMode
returns this value, entity instances within session
are or may become available (after starting access to owning model) for read-only access.
public static final int READ_WRITE
getMode
returns this value, entity instances within session
are or may become available (after starting access to owning model) for read-write access.
Method Detail |
public int getMode() throws SdaiException
SdaiTransaction
within SdaiSession
.
For data accessing, 3 modes are defined:
NO_ACCESS: the data cannot be accessed;
READ_ONLY: only read operations on the data are allowed;
READ_WRITE: read-write operations are allowed.
SdaiException
- SS_NOPN, session is not open.
SdaiException
- TR_NEXS, transaction does not exist.public SdaiSession getOwningSession() throws SdaiException
SdaiSession
object.
SdaiException
- SS_NOPN, session is not open.
SdaiException
- TR_NEXS, transaction does not exist.public void commit() throws SdaiException
SdaiModel
s in which some data were modified and whose
access mode is set. For each model, a separate binary file with the name
of that model is created.
This method also sets the change date for any model or schema instance that has been modified or created. Moreover, it sets the change date also for repository itself if some data in the repository was changed.
SdaiException
- SS_NOPN, session is not open.
SdaiException
- TR_NEXS, transaction does not exist.
SdaiException
- TR_NAVL, transaction currently not available.
SdaiException
- TR_EAB, transaction ended abnormally.
SdaiException
- SY_ERR, underlying system error.abort()
,
SdaiModel.getChangeDate()
,
SchemaInstance.getChangeDate()
,
SdaiRepository.getChangeDate()
,
"ISO 10303-22::10.4.8 Commit",
"ISO 10303-22::7.4.5 sdai_transaction"public void commit(java.lang.String appComment) throws SdaiException
appComment
- application provided comment to be recorded in JSDAI-DB
for history tracking. Application comment is ignored if
JSDAI-DB changes did not occur for the current transaction
or if JSDAI-DB does not support recording commit operations
SdaiException
- if an error occurs during the operation
or in underlying JSDAI operationscommit()
public void abort() throws SdaiException
No function is performed if access mode for this transaction is read-only. The method does not change the current access mode.
SdaiException
- SS_NOPN, session is not open.
SdaiException
- TR_NEXS, transaction does not exist.
SdaiException
- TR_NAVL, transaction currently not available.
SdaiException
- TR_EAB, transaction ended abnormally.
SdaiException
- SY_ERR, underlying system error.commit()
,
"ISO 10303-22::10.4.9 Abort",
"ISO 10303-22::7.4.5 sdai_transaction"public void endTransactionAccessCommit() throws SdaiException
SdaiException
- SS_NOPN, session is not open.
SdaiException
- TR_NEXS, transaction does not exist.
SdaiException
- TR_NAVL, transaction currently not available.
SdaiException
- TR_EAB, transaction ended abnormally.
SdaiException
- SY_ERR, underlying system error.commit()
,
SdaiSession.startTransactionReadWriteAccess()
,
SdaiSession.startTransactionReadOnlyAccess()
,
"ISO 10303-22::10.4.10 End transaction access and commit",
"ISO 10303-22::7.4.5 sdai_transaction"public void endTransactionAccessCommit(java.lang.String appComment) throws SdaiException
appComment
- application provided comment to be recorded in JSDAI-DB
for history tracking. Application comment is ignored if
JSDAI-DB changes did not occur for the current transaction
or if JSDAI-DB does not support recording commit operations
SdaiException
- if an error occurs during the operation
or in underlying JSDAI operationsendTransactionAccessCommit()
public void endTransactionAccessAbort() throws SdaiException
SdaiException
- SS_NOPN, session is not open.
SdaiException
- TR_NEXS, transaction does not exist.
SdaiException
- TR_NAVL, transaction currently not available.
SdaiException
- TR_EAB, transaction ended abnormally.
SdaiException
- SY_ERR, underlying system error.abort()
,
SdaiSession.startTransactionReadWriteAccess()
,
SdaiSession.startTransactionReadOnlyAccess()
,
"ISO 10303-22::10.4.11 End transaction access and abort",
"ISO 10303-22::7.4.5 sdai_transaction"public java.lang.String toString()
String
.
It includes constant string "SdaiTransaction mode: " and the access mode
provided by this transaction.
|
Copyright © LKSoftWare GmbH, 1999-2008 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |