COM Object Persistence using OLEDB Help 
Author Message
 COM Object Persistence using OLEDB Help

I'm trying to come up with a standard way to implement object persistence
using OLEDB, stored procedures and ATL.  If someone has already solved this
problem or knows where to go to figure this out, I would be forever in their
debt....

Most of the implementation examples I have seen so far have the actual OLEDB
code in the implementation class for the object itself.  This means that
everyone that implements a COM object needs to know how to use OLEDB.  This
simply will not do.

I want to be able to create a base class, that each COM object
implementation class derives from, that uses OLEDB in order to load/save the
object's properties from the database.  Also, I want a stored procedure to
do the work on the database side.  I simply call a stored procedure, passing
the primary key for the object and get a record set back.

The problem with this is matching up the member variables in the object
implementation class with the record set in a base class.  For this, I
thought I would use the PropertyBag interface, specifying a property map in
the object.  So, here is the order in which things should happen?

1.  Create an instance of the object.
2.  QI for the IPersistDatabase interface (I will create this).
3.  Call Load() on the IPersistDatabase interface, passing the primary key
for this object and the name of the stored procedure for the object).
4.  Call the stored procedure, getting back a record set.
4.  The Load method calls QI on the object for the IPersistPropertyBag
interface.
5.  Enumerate the properties, setting the value of each property with the
value in the record set.
6.  Save the record set so we can update the database later.
N.  When the object goes out of scope or the Save method has been called,
save the record set back to the database.

Has anyone seen anything like this before?  Is this the best way to do this
or am I just totally off key here?



Mon, 27 Oct 2003 04:33:18 GMT  
 COM Object Persistence using OLEDB Help
I'm trying to come up with a standard way to implement object persistence
using OLEDB, stored procedures and ATL.  If someone has already solved this
problem or knows where to go to figure this out, I would be forever in their
debt....

Most of the implementation examples I have seen so far have the actual OLEDB
code in the implementation class for the object itself.  This means that
everyone that implements a COM object needs to know how to use OLEDB.  This
simply will not do.

I want to be able to create a base class, that each COM object
implementation class derives from, that uses OLEDB in order to load/save the
object's properties from the database.  Also, I want a stored procedure to
do the work on the database side.  I simply call a stored procedure, passing
the primary key for the object and get a record set back.

The problem with this is matching up the member variables in the object
implementation class with the record set in a base class.  For this, I
thought I would use the PropertyBag interface, specifying a property map in
the object.  So, here is the order in which things should happen?

1.  Create an instance of the object.
2.  QI for the IPersistDatabase interface (I will create this).
3.  Call Load() on the IPersistDatabase interface, passing the primary key
for this object and the name of the stored procedure for the object).
4.  Call the stored procedure, getting back a record set.
4.  The Load method calls QI on the object for the IPersistPropertyBag
interface.
5.  Enumerate the properties, setting the value of each property with the
value in the record set.
6.  Save the record set so we can update the database later.
N.  When the object goes out of scope or the Save method has been called,
save the record set back to the database.

Has anyone seen anything like this before?  Is this the best way to do this
or am I just totally off key here?



Mon, 27 Oct 2003 04:33:02 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Problem with scripting context when using VB com object inside VC com object

2. Using COM objects within COM objects

3. ADO vs OLEDB COM vs OLEDB ATL templates

4. Need help to start using a COM object in VC app

5. Return a pointer to a nested COM object from a COM object method

6. Invoking COM object from COM object

7. passing COM object pointers to another COM object in ATL

8. COM Object returning COM Object Reference

9. COM object in a COM object

10. Passing COM objects as parameters to other COM objects

11. C++ COM-Object with COM-Object as parameter

12. Creating COM objects from COM objects

 

 
Powered by phpBB® Forum Software