|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.extentech.ExtenBean.ExtenBeanFactory
public class ExtenBeanFactory
A DataObjectFactory which populates the data in classes which implement the DataObject
interface. The factory also provides persistence services including updates, inserts
and deletes.
ExtenDataObject,
colinfo| Field Summary | |
|---|---|
Connection |
conn
|
DatabaseMetaData |
dbmd
|
Statement |
statement
|
| Constructor Summary | |
|---|---|
ExtenBeanFactory()
Blank constructor, you MUST NOW SET THE CONNECTION. |
|
ExtenBeanFactory(Connection c)
Allows the controller class to specify the connection |
|
| Method Summary | |
|---|---|
DataObject |
createNewDataObject(DataObject d)
Gets a new instance of a dataobject including empty fields. |
ResultSet |
doQuery(String query)
|
void |
doUpdate(String query)
Perform an UPDATE, INSERT or DELETE operation on the datastore |
void |
doUpdate(String[] query)
Perform a series UPDATE, INSERT or DELETE operations on the datastore |
void |
finalize()
Close all open resources and destroy object. |
Connection |
getConn()
|
String |
getDateFormat()
|
int |
getHiID(DataObject d)
Get the current HI-ID for a numeric index field. |
int |
getHiID(PageableDataObject d)
This version of getHiID() checks for support for an Oracle sequece to use for the next id |
String |
getSequenceName()
set the name of the auto-increment sequence in the DB catalog. |
String |
getStringFromBLOB(ResultSet rs,
int x)
get a String from a ResultSet CLOB |
String |
getStringFromCLOB(ResultSet rs,
int x)
get a String from a ResultSet CLOB (Oracle) |
DataObject |
initDataObject(DataObject o)
Loads data into a DataObject according to the DataObject's SQL statement. |
void |
log(String msg)
Create a log-style system output. |
void |
logerr(String msg)
Create a log-style system output. |
boolean |
removeDataObject(DataObject o)
Delete a DataObject from its persistent store. |
void |
setConn(Connection cx)
|
void |
setConnection(Connection c)
Set the database connection for this factory. |
void |
setConnection(com.extentech.dbutil.ConnectionPool c)
Set the database connection pool for this factory. |
void |
setDateBeginDelim(String s)
|
void |
setDateDelim(String s)
set special date delimiters for both the beginning and end of date values. |
void |
setDateDelim(String s,
String t)
set differing date delimiters for both the beginning and end of date values. |
void |
setDateEndDelim(String s)
|
void |
setDateFormat(String df)
|
void |
setDebug(boolean t)
|
void |
setSequenceName(String sequenceName)
set the name of the auto-increment sequence in the DB catalog. |
void |
setShowSQLOut(boolean b)
|
void |
setStripTimestampMills(boolean f)
|
void |
setTsBeginDelim(String s)
|
void |
setTsEndDelim(String s)
|
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 |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public Connection conn
public DatabaseMetaData dbmd
public Statement statement
| Constructor Detail |
|---|
public ExtenBeanFactory(Connection c)
public ExtenBeanFactory()
| Method Detail |
|---|
public void setShowSQLOut(boolean b)
public void setStripTimestampMills(boolean f)
public void setTsBeginDelim(String s)
public void setTsEndDelim(String s)
public void setDateBeginDelim(String s)
public void setDateEndDelim(String s)
public String getDateFormat()
public void setDateFormat(String df)
public void setDebug(boolean t)
public void log(String msg)
public void logerr(String msg)
public void setDateDelim(String s)
public void setDateDelim(String s,
String t)
public void finalize()
finalize in class Object
public DataObject initDataObject(DataObject o)
throws SQLException
initDataObject in interface PersistenceEngineo - The DataObject for which you are requesting data.
SQLException
public String getStringFromBLOB(ResultSet rs,
int x)
public String getStringFromCLOB(ResultSet rs,
int x)
public boolean updateDataObject(DataObject o)
throws SQLException
To change DataObject values in the underlying database:
1. Set the new values:
u.setVal("FIRSTNAME", "Joe");
DataObjectFactory.java
2. When done, use the factory method to update the database
factory.updateDataObject(u);
updateDataObject in interface PersistenceEngineo - The DataObject which you are deleting.
SQLException
public boolean storeDataObject(DataObject o)
throws SQLException
storeDataObject in interface PersistenceEngineo - The DataObject which you are inserting
SQLException
public ResultSet doQuery(String query)
throws SQLException
SQLException
public void doUpdate(String[] query)
throws SQLException
query - An array of Strings (SQL statements);
SQLException
public void doUpdate(String query)
throws SQLException
o - The DataObject for which you are requesting data.
SQLException
public DataObject createNewDataObject(DataObject d)
throws SQLException
To Create a new DataObject, set its values, then save it to the database:
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.setDOLookupField("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 database.
u.setVal(0,"FIRSTNAME", "John");
u.setVal(0,"LASTNAME", "Torres");
6. And perform the insert through the factory method:
factory.storeDataObject(i);
createNewDataObject in interface PersistenceEngineo - The DataObject which you are creating.
SQLExceptionpublic void setConnection(Connection c)
setConnection in interface PersistenceEnginepublic void setConnection(com.extentech.dbutil.ConnectionPool c)
public boolean removeDataObject(DataObject o)
throws SQLException
To delete a DataObject from the underlying database:
factory.removeDataObject(u);
removeDataObject in interface PersistenceEngineo - The DataObject which you are deleting.
SQLExceptionpublic void setSequenceName(String sequenceName)
public String getSequenceName()
public int getHiID(DataObject d)
o - The DataObject which you are deleting.
public int getHiID(PageableDataObject d)
public Connection getConn()
public void setConn(Connection cx)
conn - The conn to set.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||