|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.makumba.db.TransactionImplementation org.makumba.db.makumba.DBConnection org.makumba.db.makumba.DBConnectionWrapper
public class DBConnectionWrapper
A wrapper for db connections, used to provide a temporary that holds a reference to a permanent DBConnection
Field Summary | |
---|---|
(package private) Date |
created
|
(package private) Throwable |
t
|
(package private) DBConnection |
wrapped
|
Fields inherited from class org.makumba.db.makumba.DBConnection |
---|
dataSource, db, lockRecord, locks, whereDelim |
Fields inherited from class org.makumba.db.TransactionImplementation |
---|
ddp, qp, tp |
Constructor Summary | |
---|---|
DBConnectionWrapper(DBConnection wrapped,
String dataSource,
TransactionProvider tp)
|
|
DBConnectionWrapper(TransactionProvider tp)
|
Method Summary | |
---|---|
void |
close()
Give this connection back to the system. |
void |
commit()
Commit the transaction associated with this connection. |
void |
delete(Pointer ptr)
Delete the record pointed by the given pointer. |
int |
delete(String from,
String where,
Object parameters)
Deletes in the form delete("general.Person p", "p=$1", params) NOTE that this method does not delete subsets and subrecords |
Vector<Dictionary<String,Object>> |
executeQuery(String OQL,
Object parameterValues,
int offset,
int limit)
Execute a parametrized OQL query. |
protected void |
finalize()
|
String |
getCreationStack()
|
Database |
getHostDatabase()
|
String |
getName()
Get the name of the database in the form host[_port]_dbprotocol_dbname |
DBConnection |
getWrapped()
|
Pointer |
insert(Pointer host,
String subsetField,
Dictionary<String,Object> data)
Insert a record in a subset (1-N set) or subrecord (1-1 pointer) of the given record. |
Pointer |
insert(String type,
Dictionary<String,Object> data)
insert a record |
int |
insertFromQuery(String type,
String OQL,
Object parameterValues)
Insert the results of the query in the given type. |
void |
lock(String symbol)
Acquire a lock associated to the given application-specific symbol. |
Dictionary<String,Object> |
read(Pointer ptr,
Object fields)
Read fields of a record. |
void |
rollback()
Rollback the transaction associated with this connection. |
void |
setContext(Attributes a)
|
String |
toString()
|
void |
unlock(String symbol)
Free the lock on the given symbol, if any exists. |
int |
update(Pointer ptr,
Dictionary<String,Object> fieldsToChange)
change the record pointed by the given pointer. |
int |
update(String from,
String set,
String where,
Object parameters)
updates in the form update("general.Person p", "p.birthdate=$1", "p=$2", params) NOTE that this method does not delete subrecords if their pointers are nullified |
Methods inherited from class org.makumba.db.makumba.DBConnection |
---|
deleteLock, executeQuery, executeReadQuery, executeUpdate, getDataSource, getNullConstant, getQuery, insert, insertFromQueryImpl, setDataSource, treatParam, unlockAll, writeReadQuery |
Methods inherited from class org.makumba.db.TransactionImplementation |
---|
delete1, extractReadFields, getParameterName, getPrimaryKeyName, getPrimaryKeyName, getSetJoinSyntax, getTransactionProvider, paramsToMap, paramsToMap1, readCharEnumValues, readExternalSetValues, readIntEnumValues, readSetValues, transformTypeName, updateSet, updateWithValueDiff |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
DBConnection wrapped
Throwable t
Date created
Constructor Detail |
---|
DBConnectionWrapper(TransactionProvider tp)
DBConnectionWrapper(DBConnection wrapped, String dataSource, TransactionProvider tp)
Method Detail |
---|
public DBConnection getWrapped()
public String getName()
DBConnection
getName
in interface Database
getName
in interface Transaction
getName
in class DBConnection
public Database getHostDatabase()
getHostDatabase
in class DBConnection
public Dictionary<String,Object> read(Pointer ptr, Object fields)
Transaction
Logger
,
MakumbaSystem.setLoggingRoot(java.lang.String)
) in the
"db.query.compilation", "db.query.execution", "db.query.performance"
loggers, with
Level.INFO
logging level. "db.query.execution" also logs
Level.SEVERE
fatal errors.
read
in interface Database
read
in interface Transaction
read
in class TransactionImplementation
ptr
- the pointer to the recordfields
- the fields to read, or null to read all fields. Can be a String, String[], Enumeration or a Vector
public Vector<Dictionary<String,Object>> executeQuery(String OQL, Object parameterValues, int offset, int limit)
DBConnection
executeQuery
in interface Database
executeQuery
in interface Transaction
executeQuery
in class DBConnection
OQL
- the query to execute. Refers to parameters as $1, $2 ...parameterValues
- the arguments of the queries. Should be null if there are none. If there is only one parameter, it can
be indicated directly. If there are more parameters, they can be indicated in a Object[] or a
java.util.Vector. Named parameters can be indicated in a Map.offset
- the offset of the first record to return, 0 for firstlimit
- the maximum number of records to return, -1 for all
public Pointer insert(String type, Dictionary<String,Object> data)
DBConnection
insert
in interface Database
insert
in interface Transaction
insert
in class DBConnection
type
- the makumba type to create a new record fordata
- the field-value mapping for the new record. public Pointer insert(Pointer host, String subsetField, Dictionary<String,Object> data)
TransactionImplementation
insert
in interface Database
insert
in interface Transaction
insert
in class TransactionImplementation
host
- a pointer to the host record, to which a subrecord will be addedsubsetField
- the name of the subrecord field.data
- the field-value mapping for the new subrecord. public int insertFromQuery(String type, String OQL, Object parameterValues)
Transaction
insertFromQuery
in interface Transaction
insertFromQuery
in class TransactionImplementation
type
- the type where to insertOQL
- the OQL query to execute. Refers to parameters as $1, $2 ...parameterValues
- the parameter values. Should be null if there are no parameters. If there is only one parameter, it
can be indicated directly. If there are more parameters, they can be indicated in a Object[] or a
java.util.Vector
public int update(Pointer ptr, Dictionary<String,Object> fieldsToChange)
TransactionImplementation
update
in interface Database
update
in interface Transaction
update
in class TransactionImplementation
ptr
- pointer to the record to updatefieldsToChange
- key-value pairs for the fields to modify. Pointer.Null
,
Pointer.NullInteger
,
Pointer.NullString
,
Pointer.NullText
,
Pointer.NullDate
,
Pointer.NullSet
public int update(String from, String set, String where, Object parameters)
TransactionImplementation
update
in interface Database
update
in interface Transaction
update
in class TransactionImplementation
from
- a makumba type in which update will take place, for example "general.Person p"set
- the assignments made by the update, as OQL expression e.g. "p.birthdate=$1". Use "nil" for null
assignments.where
- the OQL conditions selecting the objects on which the update will be made, e.g. "p=$2"parameters
- the parameter values. Should be null if there are no parameters. If there is only one parameter, it
can be indicated directly. If there are more parameters, they can be indicated in a Object[] or a
java.util.Vector
public void delete(Pointer ptr)
TransactionImplementation
delete
in interface Database
delete
in interface Transaction
delete
in class TransactionImplementation
ptr
- the pointer to the record to be deletedpublic int delete(String from, String where, Object parameters)
TransactionImplementation
delete
in interface Database
delete
in interface Transaction
delete
in class TransactionImplementation
from
- a makumba type in which delete will take place, for example "general.Person p"where
- the OQL conditions selecting the objects to be deleted, e.g. "p=$1"parameters
- the parameter values. Should be null if there are no parameters. If there is only one parameter, it
can be indicated directly. If there are more parameters, they can be indicated in a Object[] or a
java.util.Vector
public void commit()
Transaction
commit
in interface Database
commit
in interface Transaction
commit
in class TransactionImplementation
public void rollback()
Transaction
rollback
in interface Database
rollback
in interface Transaction
rollback
in class TransactionImplementation
public void lock(String symbol)
Transaction
lock
in interface Database
lock
in interface Transaction
lock
in class DBConnection
public void unlock(String symbol)
Transaction
unlock
in interface Database
unlock
in interface Transaction
unlock
in class DBConnection
public void close()
Transaction
close
in interface Database
close
in interface Transaction
close
in class TransactionImplementation
protected void finalize()
finalize
in class Object
public void setContext(Attributes a)
setContext
in class TransactionImplementation
public String getCreationStack()
public String toString()
toString
in class Object
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |