Re: OO DB question



"Chris" <misterjingo@xxxxxxxxx> a écrit dans le message de news:
Pwtrf.22569$D47.1411@xxxxxxxxxxxxxxxxxxxxxxxxxxxx

| >I had a OO model worked out which involved forms populating new instances
| >of a class and being stored in an ArrayList. I'm now moving this over to
a
| >DB backend rather than a file - I've been wondering if I even need to
| >create objects now? Could I just work directly with the DB e.g. form data
| >will pass directly to db handled in click events, the listview of objects
| >can be read straight from db (no need to instantiate classes).
| > I guess I'm after opinions on what others would do in these
circumstances.
| > Would it be ok to interact directly with the DB, or should I use the
class
| > instances as interfaces to the DB through their properties? Would this
| > mean I'd just instantiate a class to pass data to and from DB and then
| > dispose of it? Or keep one instance of each class to act as an
interface?
| >
| > Any opinions would be appreciated,
| >
| > Chris
| >
| > Ps Merry Christmas
| >
|
| Just to clarify, when I say create objects, I originally had objects for
| each form (a diary page) which stored all the text and options. This was
| placed in an ArrayList and output to a file on saving.

Whether you are using a file or a database to store your objects, you will
still need to manage your object's lifetimes. At the moment I presume you
are loading all your objects from the file at the start of the application
and then saving them back at the end; this is similar to the Prevayler
approach.

We have designed an Object Persistence Framework. This allows us to write
code to store and retrieve objects, regardless of the ultimate storage
mechanism. Our framework is primarily concerned with using an SQL database
but the beauty of designing an OPF is that we could read objects in from a
text or XML file and then write them back out to an SQL database, or vice
versa.

Typical client code looks like :

{
Customer c = new Customer();
c.Name = "Joanna";
// set other properties

PersistenceBroker.StoreObject(c);

Criteria crit = new EqualsCriteria<Order>("Customer", c);

List<Order> orders = PersistenceBroker.RetrieveList<Order>(crit);
...

}

>From the client side, there is nothing to say what is being used for
storage, but the Broker could well have more than one data storage
Connection and you would maintain a register that records which Connection
is responsibel for storing which types of objects.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer



.



Relevant Pages

  • Re: Persistence
    ... bound objects to permanent storage thereby allowing them to live longer ... A SQL database is obviously not the right tool for doing that. ... Persistence is strictly about object IO. ... The relational model has nothing to do with object persistence. ...
    (comp.object)
  • Not enough storage is available to complete this operation
    ... The following error message is received during the transformation of ... data from a text file into SQL database. ... "Not enough storage is available to complete this operation" ...
    (microsoft.public.sqlserver.dts)
  • Boolean vs. Byte data types
    ... I have 4 columns in a sql database which contain the value 0 or 1. ... speed/storage standpoint, does it make any difference whether I treat these ... in storage size and transmittal rate than a system.byte. ...
    (microsoft.public.dotnet.framework.adonet)
  • self contained database?
    ... I am writting a Asp.NET custom control in which I need to use some data ... storage where people can add/modify. ... I have to move the SQL database as well. ...
    (microsoft.public.dotnet.framework)