|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tentackle.db.DbObject
org.tentackle.db.ObjectId
public class ObjectId
A DbObject implementing IdSource used to create unique object IDs.
As the object-id is stored in a separate table, an instance of an object is used to retrieve a new (unique) ID for a DbObject.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.tentackle.db.DbObject |
|---|
DbObject.CopyAllToDbLogger, DbObject.IdComparator<T extends DbObject>, DbObject.NameComparator<T extends DbObject>, DbObject.NameIdComparator<T extends DbObject> |
| Field Summary | |
|---|---|
static String |
TABLENAME
the table name |
| Fields inherited from class org.tentackle.db.DbObject |
|---|
BEGIN, COMMIT, DELETE, DELETEALL, FIELD_ID, FIELD_SERIAL, FIELD_TABLESERIAL, idComparator, INSERT, lazyMethodInterval, nameComparator, nameIdComparator, TX_DELETE_LIST, TX_DELETE_MISSING_IN_LIST, TX_DELETE_OBJECT, TX_DUMMY_UPDATE, TX_INSERT_OBJECT, TX_INSERT_PLAIN, TX_SAVE, TX_SAVE_LIST, TX_UPDATE_OBJECT, TX_UPDATE_PLAIN, TX_UPDATE_SERIAL, TX_UPDATE_SERIAL_AND_TABLESERIAL, TX_UPDATE_TABLESERIAL, UPDATE |
| Constructor Summary | |
|---|---|
ObjectId()
|
|
ObjectId(Db db)
Creates a new unique object ID. |
|
| Method Summary | |
|---|---|
void |
commit()
Performs any processing necessary before commit. |
DbObjectClassVariables |
getDbObjectClassVariables()
Gets the some attributes and variables common to all objects of the same class. |
boolean |
getFields(ResultSetWrapper rs)
Retrieves the values of all fields (all columns of the database table) in the given ResultSetWrapper and stores them in the object's attributes. |
boolean |
insert()
Inserts this (new) object into the database with linked objects. |
DbObject |
newObject()
Creates a new object with the same class and same logical db connection as this object. |
long |
nextId()
Retrieves the next ID and updates the table. |
int |
prepareDeleteStatement()
Prepares the delete statement (usually the same for all objects) |
int |
prepareInsertStatement()
Prepares the insert statement. |
int |
prepareUpdateStatement()
Prepare the update statement. |
void |
returnId(long id)
Return an ID back to the pool |
DbObject |
select(long id)
Loads an object from the database by its unique ID. |
int |
setFields(PreparedStatementWrapper st)
Sets the values of all fields (all columns of the database table) in the given PreparedStatementWrapper from the object's attributes. |
boolean |
update()
Updates this object to the database. The modified attribute gets cleared if insert was successful. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String TABLENAME
| Constructor Detail |
|---|
public ObjectId(Db db)
use new ObjectId(db).getId() to get a new id for a DbObject.
db - the database connectionpublic ObjectId()
| Method Detail |
|---|
public long nextId()
throws ApplicationException
nextId in interface IdSourceApplicationException - if ID could not be createdpublic DbObject newObject()
DbObject
newObject in class DbObject
public void returnId(long id)
throws ApplicationException
IdSource
returnId in interface IdSourceid - ID to be returned
ApplicationException - if ID could not be returnedpublic void commit()
CommitTxRunnable
commit in interface CommitTxRunnablepublic boolean insert()
DbObject
The modified attribute gets cleared if insert was successful.
It is also verified that the object DbObject.isSaveable().
Note: this method does *NOT* set the ID and should be used
by the application with great care! Use DbObject.save() instead!
insert in class DbObjectpublic boolean update()
DbObjectDbObject.isSaveable().
Note: this method should be used by the application with great care!
Use DbObject.save() instead!
update in class DbObjectpublic DbObject select(long id)
DbObjectFor local db connections the current object's attributes will be replaced by the database values (i.e. this object is returned). For remote connections, a copy of the object in the server is returned. Hence, applications should always create a new object and invoke select and don't make any further assumptions. This applies to all select methods returning an object! Example:
Customer customer = new Customer(db).select(customerId);
Since Java 1.5 covariance is supported and you should consider
overriding the method and cast the return value to the appropriate class.
select in class DbObjectid - is the object id
public int setFields(PreparedStatementWrapper st)
DbObjectPreparedStatementWrapper from the object's attributes.
setFields in class DbObjectst - the statement
public boolean getFields(ResultSetWrapper rs)
DbObjectResultSetWrapper and stores them in the object's attributes.
getFields in class DbObjectrs - the result set
public int prepareUpdateStatement()
DbObject
prepareUpdateStatement in class DbObjectpublic int prepareInsertStatement()
DbObject
prepareInsertStatement in class DbObjectpublic int prepareDeleteStatement()
DbObject
prepareDeleteStatement in class DbObjectpublic DbObjectClassVariables getDbObjectClassVariables()
DbObjectDbObjectClassVariables.
getDbObjectClassVariables in class DbObject
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||