jnicli
Class DatabaseSessionClient

java.lang.Object
  extended byjnicli.DatabaseSessionClient
All Implemented Interfaces:
Database

public class DatabaseSessionClient
extends java.lang.Object
implements Database

Database session client implementation. This class implements Database interface using proxy object to access remote database server. The role of this class is to keep session context.


Field Summary
 
Fields inherited from interface jnicli.Database
AUTOCOMMIT, CLI_DETACH_COMMIT, CLI_DETACH_DEFAULT, CLI_DETACH_DESTROY_CONTEXT, CONCURRENT_READ, CONCURRENT_UPDATE, FOR_UPDATE, READ_ONLY, READ_WRITE
 
Constructor Summary
DatabaseSessionClient(DatabaseSession proxy)
           
 
Method Summary
 void attach()
          Attach thread to the database.
 void close()
          Close database
 void commit()
          Commit current transaction.
 int delete(java.lang.Class table, java.lang.String condition)
          Delete all objects from the table matching specified condition
 void detach(int flags)
          Detach thread to the database.
 long insert(java.lang.Object obj)
          Insert new object in the database.
 void lock()
          Lock database in exclusive mode.
 void open(int accessType, java.lang.String databaseName, java.lang.String databasePath, long initSize, int transactionCommitDelay)
          Open database
 void rollback()
          Commit current transaction Transaction is implicitly started when any database operation is perfromed.
 Cursor select(java.lang.Class table, java.lang.String condition, int flags)
          Select objects from table matching condition
 void update(long oid, java.lang.Object obj)
          Update object with soecified OID
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseSessionClient

public DatabaseSessionClient(DatabaseSession proxy)
Method Detail

open

public void open(int accessType,
                 java.lang.String databaseName,
                 java.lang.String databasePath,
                 long initSize,
                 int transactionCommitDelay)
Description copied from interface: Database
Open database

Specified by:
open in interface Database
Parameters:
accessType - database access type: one of READ_ONLY, READ_WRITE, CONCURRENT_READ or CONCURRENT_UPDATE
databaseName - database name
databasePath - path to the database file
initSize - initial size of database
transactionCommitDelay - transaction commit delay (specify 0 to disable)

close

public void close()
Description copied from interface: Database
Close database

Specified by:
close in interface Database

select

public Cursor select(java.lang.Class table,
                     java.lang.String condition,
                     int flags)
Description copied from interface: Database
Select objects from table matching condition

Specified by:
select in interface Database
Parameters:
table - class corresponding to the table
condition - SubSQL condition (to select all records pass empty string)
flags - combination of FOR_UPDATE and AUTOCOMMIT flags
Returns:
cursor for selected objects. Cursor can be either incremental, when records are extracted on demand or prefetched. Prefetched cursor is used for remote database and when AUTOCOMMIT flag is set. Prefetched cursor doesn't allow in place updates.

update

public void update(long oid,
                   java.lang.Object obj)
Description copied from interface: Database
Update object with soecified OID

Specified by:
update in interface Database
Parameters:
oid - OID of updated object
obj - updated object

insert

public long insert(java.lang.Object obj)
Description copied from interface: Database
Insert new object in the database. Object will be inserted in the table with the same name as object class

Specified by:
insert in interface Database
Parameters:
obj - inserted object
Returns:
OID of inserted object

delete

public int delete(java.lang.Class table,
                  java.lang.String condition)
Description copied from interface: Database
Delete all objects from the table matching specified condition

Specified by:
delete in interface Database
Parameters:
table - class corresponding to the table
condition - SubSQL condition (to delete all records pass empty string)
Returns:
number of deleted objects

commit

public void commit()
Description copied from interface: Database
Commit current transaction. Transaction is implicitly started when any database operation is perfromed.

Specified by:
commit in interface Database

rollback

public void rollback()
Description copied from interface: Database
Commit current transaction Transaction is implicitly started when any database operation is perfromed.

Specified by:
rollback in interface Database

lock

public void lock()
Description copied from interface: Database
Lock database in exclusive mode. Lock is automatically released when transaction is committed or aborted

Specified by:
lock in interface Database

attach

public void attach()
Description copied from interface: Database
Attach thread to the database. All threads except the one opened the database should invoke this method before start working with database

Specified by:
attach in interface Database

detach

public void detach(int flags)
Description copied from interface: Database
Detach thread to the database. All threads except the one opened the database should invoke this method before start working with database

Specified by:
detach in interface Database
Parameters:
flags - combination of CLI_DETACH_COMMIT and CLI_DETACH_DESTROY_CONTEXT flags