Re: OO DB question
- From: "Joanna Carter [TeamB]" <joanna@xxxxxxxxxxxx>
- Date: Sun, 25 Dec 2005 18:50:31 -0000
"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
.
- Follow-Ups:
- Re: OO DB question
- From: Joanna Carter [TeamB]
- Re: OO DB question
- References:
- OO DB question
- From: Chris
- Re: OO DB question
- From: Chris
- OO DB question
- Prev by Date: Re: Struct faster than class?
- Next by Date: null, list and generics
- Previous by thread: Re: OO DB question
- Next by thread: Re: OO DB question
- Index(es):
Relevant Pages
|