Hi Jim,

> I'm working on a webapp using OJB, and have 2
> questions on persistence broker usage patterns. 
> 
> 1. I have read the beer4all example and the Struts
> book, and understand why they use an interface to hide
> OJB from web application. However, the example only
> addresses object retrival, not insert/update/delete. I
> wonder what is the general pattern regarding these
> i/u/d operations? Should I add a set of methods for
> each business objects I interested in (i.e.
> insertUser/updateUser/insertItem/deleteItem, etc)? Or
> should I just add 3 generic methods for all business
> objects (i.e. insert/update/delete)?

I am using a mixture of these approaches. A Facade pattern hides almost all
of the OJB classes, and offers generic lifecycle methods to my application
(insert, delete etc.) For each of the persistent classes I've defined
"Manager" classes which provide the standard set of lifecycle methods from
the Facade, as well as special methods for certain classes. (Subclassing the 
Manager classes from an abstract superclass means there is not much work 
involved in creating one). The Manager classes are the only classes to use 
the Facade. It works fairly well; one thing which it doesn't do very cleanly
is hide complex (non-lifecycle) queries.

> 2. When using the persistence broker, should I keep
> one broker for every operation inside my application
> (i.e. a singleton) or should I create one for an
> operation and close it immediately after the operation
> (i.e. like a database connection)?

The brokers are pooled, so as far as I know they can be created and
closed with every database operation (this is what I am doing).
 
> 3. PBKey: What is the design rational behind this
> class? Is it just a simple way to group repository.xml
> and user/password?

AFAIK, a wrapper for OJB.properties - you create one once (and parse the OJB
configuration), and can then create as many brokers from it as you need. 

Hope this helps,

Will

-- 
William Mee

IVISTAR Kommunikationssysteme AG (www.ivistar.de)
Ehrenbergstra�e 19
10245 Berlin, Germany
Tel: +49-(0)30-44678224
Fax: +49-(0)30-44678223

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to