|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface PersistenceEngine
The PersistenceEngine interface defines persistence services for DatObjects
ExtenBeanFactory,
DataObject,
colinfo| Method Summary | |
|---|---|
DataObject |
createNewDataObject(DataObject d)
Gets a new instance of a dataobject including empty fields. |
DataObject |
initDataObject(DataObject o)
Loads data into a DataObject according to the DataObject's SQL statement. |
boolean |
removeDataObject(DataObject o)
Delete a DataObject from its persistent store. |
void |
setConnection(Connection c)
Set the database connection for this factory. |
boolean |
storeDataObject(DataObject o)
Insert a new DataObject into its persistent store. |
boolean |
updateDataObject(DataObject o)
Persist changes to a DataObject back to its datastore |
| Method Detail |
|---|
void setConnection(Connection c)
DataObject initDataObject(DataObject o)
throws SQLException
o - The DataObject for which you are requesting data.
SQLException
boolean updateDataObject(DataObject o)
throws SQLException
To change DataObject values in the underlying datasource:
1. Set the new values:
u.setVal("FIRSTNAME", "Joe");
2. When done making changes, to persist to data store:
u.store();
Or you can use the factory method to update the datasource:
factory.updateDataObject(u);
o - The DataObject which you are deleting.
SQLException
boolean storeDataObject(DataObject o)
throws SQLException
o - The DataObject which you are deleting.
SQLException
boolean removeDataObject(DataObject o)
throws SQLException
To delete a DataObject from the underlying datasource:
factory.removeDataObject(u);
o - The DataObject which you are deleting.
SQLException
DataObject createNewDataObject(DataObject d)
throws SQLException
To Create a new DataObject, set its values, then save it to the datasource:
1. Use the new constructor to get an empty instance:
User u = new User();
2. Set the name of the table that you want to insert this object
into, as well as the key column that the bean will use to perform
the insert.
i.setTableName("USERS");
i.setKeyCol("ID");
3. Create (or use an existing) DataObjectFactory to do
the work of populating the data.
DataObjectFactory factory = new DataObjectFactory();
4. Send the DataObject to the factory to get its MetaData information:
u = factory.createNewDataObject(u);
5. Use the methods of the empty object to set
the data. The setVal command will set values based on
the name of the columns in the datasource.
u.setVal(0,"FIRSTNAME", "John");
u.setVal(0,"LASTNAME", "Torres");
6. And perform the insert through the factory method:
factory.storeDataObject(i);
o - The DataObject which you are creating.
SQLException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||