com.extentech.ExtenBean
Interface PersistenceEngine

All Known Implementing Classes:
ExtenBeanFactory, PagedDataFactory, WorkBookBeanFactory, XMLDataObjectFactory

public interface PersistenceEngine

The PersistenceEngine interface defines persistence services for DatObjects

Version:
1.1
Author:
John McMahon -- Copyright ©2011Extentech Inc.
See Also:
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

setConnection

void setConnection(Connection c)
Set the database connection for this factory.


initDataObject

DataObject initDataObject(DataObject o)
                          throws SQLException
Loads data into a DataObject according to the DataObject's SQL statement.

Parameters:
o - The DataObject for which you are requesting data.
Returns:
The DataObject populated with data.
Throws:
SQLException

updateDataObject

boolean updateDataObject(DataObject o)
                         throws SQLException
Persist changes to a DataObject back to its datastore

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);

Parameters:
o - The DataObject which you are deleting.
Returns:
Whether the operation succeeded.
Throws:
SQLException

storeDataObject

boolean storeDataObject(DataObject o)
                        throws SQLException
Insert a new DataObject into its persistent store.

Parameters:
o - The DataObject which you are deleting.
Returns:
Whether the operation succeeded.
Throws:
SQLException

removeDataObject

boolean removeDataObject(DataObject o)
                         throws SQLException
Delete a DataObject from its persistent store.

To delete a DataObject from the underlying datasource:
factory.removeDataObject(u);

Parameters:
o - The DataObject which you are deleting.
Returns:
Whether the operation succeeded.
Throws:
SQLException

createNewDataObject

DataObject createNewDataObject(DataObject d)
                               throws SQLException
Gets a new instance of a dataobject including empty fields.

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);

Parameters:
o - The DataObject which you are creating.
Returns:
a new dataobject
Throws:
SQLException


Copyright © 2011 Extentech Inc. All Rights Reserved.