Database

Description

Database access functions

Functions

NameSignature and Synopsis
assertDBInstancevoid assertDBInstance(Concept instance, boolean deep)
Asserts a DB Concept instance into working memory. If deep is set to true then asserts all contained/referenced DB concept instances
beginTransactionvoid beginTransaction()
Begins a transaction on the current connection.
commitvoid commit()
Commits the current transaction.
deleteint delete(Concept instance, boolean cascade)
Deletes rows from the database based on primary key values of the passed instance. If cascade is set to true, deletes all rows corresponding to its contained concept and concept reference properties. Further, for concept reference properties, updates other tables by setting their foreign key references to null for those rows that match primary keys of the rows being deleted
executePreparedStmtint executePreparedStmt(String preparedStmt, Object[] args)
Executes a PreparedStatement. A prepared statement is a SQL statement where values are determined at runtime. The values to be used are passed as an array of objects.
executeSQLint executeSQL(String sql)
Executes an SQL statement. To be used for inserts/updates and deletes.
getConnectionStatusint getConnectionStatus(String jdbcResourceURI)
Returns the status of connections for the given JDBC URI If underlying connections are good, returns 1, else returns 0
insertConcept insert(Concept instance)
Inserts a record corresponding to the passed DB concept, into the database. If the passed instance contains concept references, then all such instances are inserted recursively. Primary keys are either generated using sequences (based on sequences.xml in the project) or have to be specified in the instance.
queryUsingConceptPropsConcept[] queryUsingConceptProps(Concept qConcept, boolean queryChildren)
Queries database using the values in a concept instance.
queryUsingPreparedStmtConcept[] queryUsingPreparedStmt(String conceptURI, String preparedStmt, Object[] args, boolean queryChildren)
Queries the database using the supplied prepared statement.
queryUsingPrimaryKeysConcept[] queryUsingPrimaryKeys(String conceptURI, SimpleEvent pKeyEvent, boolean queryChildren)
Queries the database using primary key values provided in an Event.
queryUsingSQLConcept[] queryUsingSQL(String conceptURI, String sql, boolean queryChildren)
Queries underlying database using the supplied SQL.
rollbackvoid rollback()
Rolls back current transaction.
setCurrentConnectionvoid setCurrentConnection(String jdbcResourceURI)
Sets the connection to use for database operations.
unsetConnectionvoid unsetConnection()
Releases the current connection back to the connection pool. To be called each time after performing database operations.
updateint update(Concept instance)
Updates the database using values in the passed concept