Class JOP.persist.jdbc.JdbcPersistManager
All Packages Class Hierarchy This Package Previous Next Index Home
Class JOP.persist.jdbc.JdbcPersistManager
java.lang.Object
|
+----JOP.persist.PersistManager
|
+----JOP.persist.jdbc.JdbcPersistManager
- public class JdbcPersistManager
- extends PersistManager
The JdbcPersistManager supports saving
and retrieving objects, and complex graphs of
objects to a database via JDBC. The JdbcPersistManager works with
any JDBC data source and will run on all Java platforms where
JDBC is available.
Before using JdbcPersistManager you should configure the
database using JOP.persist.jdbc.JdbcConfig
The JdbcPersistManager implements several useful features:
-
Automatic Schema Creation. The generated schema is quite
straightforward and can be used from end-user
query tools or other applications.
-
cached reads within a unit of work
-
only updates where objects have changed (to be implemented)
-
transaction support via the unit of work
-
efficient SQL retrieval for slots (attributes) of an object
-
in-line support for simple object types (such as String)
thereby using foreign keys only where necessary
There are several features on the drawing board, yet to be included in
this class including mutli-user support and optimistic locking.
- See Also:
- JdbcConfig
-
JdbcPersistManager(String, String, String, String)
- Alternate constructor where user_name = dbo_user_name
-
JdbcPersistManager(String, String, String, String, String, String)
- Prepares to open a connection to a specific database server.
-
close()
- Close a previously open connection to the persistent
data source.
-
open()
- Establish the connection to the datasource via
JDBC using the information passed to the constructor.
-
streamInObject(long)
- Retrieves an object previously saved by 'streamOutObject()'.
-
streamOutObject(Object)
- Save the object on the database.
JdbcPersistManager
public JdbcPersistManager(String driver,
String url,
String unam,
String upwd,
String onam,
String opwd) throws Exception
- Prepares to open a connection to a specific database server. Both a
normal user name and a database owner (dbo) user name can be specified.
The dbo user name is used for all table and index creation
operations.
This method does not open the connection, but rather
prepares the information needed to open the connection.
The open() method should be invoked to complete the connection.
- See Also:
- open
JdbcPersistManager
public JdbcPersistManager(String driver,
String url,
String unam,
String upwd) throws Exception
- Alternate constructor where user_name = dbo_user_name
open
public void open() throws Exception
- Establish the connection to the datasource via
JDBC using the information passed to the constructor.
- Overrides:
- open in class PersistManager
close
public void close() throws Exception
- Close a previously open connection to the persistent
data source.
- Overrides:
- close in class PersistManager
streamOutObject
public long streamOutObject(Object o) throws Exception
- Save the object on the database. The object can
implement Persistable, have a custom marshall
class available or can be automatically marshalled. The
object and all of the objects referenced by the
object are saved. Loops are detected and
avoided.
To retrieve the object call 'streamInObject()'
- Parameters:
- o - The object to be saved
- Returns:
- s The unique identifier of the object
- Overrides:
- streamOutObject in class PersistManager
- See Also:
- streamInObject
streamInObject
public Object streamInObject(long xid) throws Exception
- Retrieves an object previously saved by 'streamOutObject()'.
The unique object id is passed and an object and all
of the objects referenced by the object are
returned. The object will be an instance of the same type
that was saved and will have the same context. The
caller of this method must explicitly
cast the returned object before using it.
Within a consistency unit multiple reads of an object
either directly (via this method) or indirectly because
the object is referenced by another object will not
create secondary instances.
- Parameters:
- id - Unique indentifier of the object
- Returns:
- s The object
- Overrides:
- streamInObject in class PersistManager
- See Also:
- streamInObject, streamOutObject
All Packages Class Hierarchy This Package Previous Next Index Home