|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||
java.lang.Objectorg.makumba.db.TransactionImplementation
public abstract class TransactionImplementation
Abstract Transaction, with helper methods for both concrete implementations
| Field Summary | |
|---|---|
protected DataDefinitionProvider |
ddp
|
protected QueryProvider |
qp
|
protected TransactionProvider |
tp
|
| Constructor Summary | |
|---|---|
TransactionImplementation(TransactionProvider tp)
|
|
| Method Summary | ||
|---|---|---|
abstract void |
close()
Give this connection back to the system. |
|
abstract 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 |
|
void |
delete1(Pointer ptr)
|
|
abstract Vector<Dictionary<String,Object>> |
executeQuery(String OQL,
Object parameterValues)
Execute query without limiting the results. |
|
abstract Vector<Dictionary<String,Object>> |
executeQuery(String OQL,
Object parameterValues,
int offset,
int limit)
Execute a parametrized OQL query. |
|
protected abstract Vector<Dictionary<String,Object>> |
executeReadQuery(Pointer p,
StringBuffer sb)
|
|
protected abstract int |
executeUpdate(String type,
String set,
String where,
Object args)
Executes an UPDATE statement or a DELETE FROM statement, depending on the value of set. |
|
protected Enumeration<String> |
extractReadFields(Pointer p,
Object flds)
|
|
abstract String |
getDataSource()
Returns the name of the data source to which this Transaction is connected |
|
abstract String |
getName()
Get the name of the database in the form host[_port]_dbprotocol_dbname |
|
abstract String |
getNullConstant()
|
|
String |
getParameterName()
|
|
String |
getPrimaryKeyName()
|
|
String |
getPrimaryKeyName(String ptrDD)
|
|
String |
getSetJoinSyntax()
|
|
TransactionProvider |
getTransactionProvider()
Returns the TransactionProvider which created this Transaction |
|
Pointer |
insert(Pointer base,
String field,
Dictionary<String,Object> data)
Insert a record in a subset (1-N set) or subrecord (1-1 pointer) of the given record. |
|
Vector<Pointer> |
insert(String type,
Collection<Dictionary<String,Object>> data)
Performs a batch insert. |
|
Pointer |
insert(String type,
Dictionary<String,Object> data)
Insert a record of the given type. |
|
int |
insertFromQuery(String type,
String OQL,
Object parameterValues)
Insert the results of the query in the given type. |
|
protected abstract int |
insertFromQueryImpl(String type,
String OQL,
Object parameterValues)
|
|
abstract void |
lock(String symbol)
Acquire a lock associated to the given application-specific symbol. |
|
protected Map<String,Object> |
paramsToMap(Object args)
Takes a heterogeneous argument object (coming from the BL API or the view layer) and transforms it into a Map Attributes) |
|
protected Map<String,Object> |
paramsToMap1(Object args)
|
|
Dictionary<String,Object> |
read(Pointer p,
Object flds)
Read fields of a record. |
|
Vector<String> |
readCharEnumValues(Pointer basePointer,
String setName)
|
|
Vector<Pointer> |
readExternalSetValues(Pointer basePointer,
String setName)
Convenience method to read all the values of an external set into one Collection. |
|
Vector<Integer> |
readIntEnumValues(Pointer basePointer,
String setName)
|
|
protected
|
readSetValues(Pointer basePointer,
String setName)
|
|
abstract void |
rollback()
Rollback the transaction associated with this connection. |
|
void |
setContext(Attributes a)
|
|
String |
transformTypeName(String name)
|
|
abstract 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 |
|
int |
updateSet(Pointer basePointer,
String setName,
Collection<?> addElements,
Collection<?> removeElements)
Convenience method to update the values of an external set. |
|
ArrayList<FieldValueDiff> |
updateWithValueDiff(Pointer ptr,
Dictionary<String,Object> fieldsToChange)
|
|
protected abstract StringBuffer |
writeReadQuery(Pointer p,
Enumeration<String> e)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected DataDefinitionProvider ddp
protected QueryProvider qp
protected TransactionProvider tp
| Constructor Detail |
|---|
public TransactionImplementation(TransactionProvider tp)
| Method Detail |
|---|
public abstract void close()
Transaction
close in interface Databaseclose in interface Transactionpublic abstract void commit()
Transaction
commit in interface Databasecommit in interface Transactionpublic abstract void rollback()
Transaction
rollback in interface Databaserollback in interface Transactionpublic abstract String getName()
Transaction
getName in interface DatabasegetName in interface Transactionpublic abstract void lock(String symbol)
Transaction
lock in interface Databaselock in interface Transactionpublic abstract void unlock(String symbol)
Transaction
unlock in interface Databaseunlock in interface Transaction
protected abstract int executeUpdate(String type,
String set,
String where,
Object args)
type - the type on which to perform the operationset - the SET part of the query. if null, this performs a DELETE FROM statementwhere - the WHERE part of the queryargs - the query arguments
INSERT, UPDATE, or DELETE statements
or (2) 0 for SQL statements that return nothingpublic void delete(Pointer ptr)
delete in interface Databasedelete in interface Transactionptr - the pointer to the record to be deleted
public int delete(String from,
String where,
Object parameters)
delete in interface Databasedelete in interface Transactionfrom - 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 abstract Vector<Dictionary<String,Object>> executeQuery(String OQL,
Object parameterValues,
int offset,
int limit)
TransactionLogger,
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.
executeQuery in interface DatabaseexecuteQuery in interface TransactionOQL - 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 abstract Vector<Dictionary<String,Object>> executeQuery(String OQL,
Object parameterValues)
Transaction
executeQuery in interface DatabaseexecuteQuery in interface TransactionTransaction.executeQuery(java.lang.String,java.lang.Object,int,int)public TransactionProvider getTransactionProvider()
Transaction
getTransactionProvider in interface Transaction
public Pointer insert(String type,
Dictionary<String,Object> data)
TransactionLogger,
MakumbaSystem.setLoggingRoot(java.lang.String)) in the
"db.update.execution", "db.update.performance" loggers, with
Level.INFO logging level. "db.update.execution" also logs
Level.SEVERE fatal errors.
Special makumba fields are treated as follows:
insert in interface Databaseinsert in interface Transactiontype - the makumba type to create a new record fordata - the field-value mapping for the new record.
public Vector<Pointer> insert(String type,
Collection<Dictionary<String,Object>> data)
TransactionTransaction.insert(String, Dictionary), only
that a collection is provided instead of a single Dictionary.
insert in interface Transactiontype - the makumba type to create a new record fordata - a set of field-value mapping for the new record.
public Pointer insert(Pointer base,
String field,
Dictionary<String,Object> data)
insert in interface Databaseinsert in interface Transactionbase - a pointer to the host record, to which a subrecord will be addedfield - 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 Transactiontype - 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
protected abstract int insertFromQueryImpl(String type,
String OQL,
Object parameterValues)
protected abstract StringBuffer writeReadQuery(Pointer p,
Enumeration<String> e)
public int update(Pointer ptr,
Dictionary<String,Object> fieldsToChange)
update in interface Databaseupdate in interface Transactionptr - 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 ArrayList<FieldValueDiff> updateWithValueDiff(Pointer ptr,
Dictionary<String,Object> fieldsToChange)
updateWithValueDiff in interface Transaction
public int updateSet(Pointer basePointer,
String setName,
Collection<?> addElements,
Collection<?> removeElements)
TransactionsetName of the object basePointer into a
collection, using Transaction.readExternalSetValues(Pointer, String)deleteElementsnewElementsTransaction.update(Pointer, Dictionary) to write the new set values to the database
updateSet in interface TransactionbasePointer - pointer to the record to updatesetName - the name of the external set in the type of basePointeraddElements - A Collection of String or Pointer (the type can vary for each collection
element) of new objects to add to existing set elementsremoveElements - A Collection of String or Pointer (the type can vary for each collection
element) of objects that should be removed from the existing set elements
public Vector<Pointer> readExternalSetValues(Pointer basePointer,
String setName)
TransactionCollection. This method is a
shortcut to other Makumba API and Java methods, and basically does the following steps:
Transaction.executeQuery(String, Object) to read all the values of the field setName of the
object basePointer.Vector> into a Vector
readExternalSetValues in interface TransactionbasePointer - pointer to the record to updatesetName - the name of the external set in the type of basePointer
Vector containing the Pointer of the external set
public Vector<Integer> readIntEnumValues(Pointer basePointer,
String setName)
readIntEnumValues in interface Transaction
public Vector<String> readCharEnumValues(Pointer basePointer,
String setName)
readCharEnumValues in interface Transaction
protected <T> Vector<T> readSetValues(Pointer basePointer,
String setName)
public int update(String from,
String set,
String where,
Object parameters)
update in interface Databaseupdate in interface Transactionfrom - 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 Dictionary<String,Object> read(Pointer p,
Object flds)
TransactionLogger,
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 Databaseread in interface Transactionp - the pointer to the recordflds - the fields to read, or null to read all fields. Can be a String, String[], Enumeration or a Vector
protected Enumeration<String> extractReadFields(Pointer p,
Object flds)
throws ProgrammerError
ProgrammerError
protected abstract Vector<Dictionary<String,Object>> executeReadQuery(Pointer p,
StringBuffer sb)
public void delete1(Pointer ptr)
public String getSetJoinSyntax()
protected Map<String,Object> paramsToMap(Object args)
Attributes)
protected Map<String,Object> paramsToMap1(Object args)
public String transformTypeName(String name)
public String getParameterName()
public String getPrimaryKeyName()
public String getPrimaryKeyName(String ptrDD)
public abstract String getNullConstant()
public abstract String getDataSource()
Transaction
getDataSource in interface Transactionpublic void setContext(Attributes a)
|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||