Armin wrote:
> I think your analysis is correct and the listener show the expected
> behavior, see javadoc
>
> http://db.apache.org/ojb/api/org/apache/ojb/broker/PersistenceBroker.html#addListener(org.apache.ojb.broker.PBListener)
>
> the temporary listener will only be removed on the PB.close() call. It's
> strongly recommended to close each used PB instance immediately after
> use (or guarantee that it is happen sometime), because only in this case
> OJB is able to do all needed cleanup. All PB instances are pooled, so
> this procedure doesn't affect performance.
> Here is a usage example
> http://db.apache.org/ojb/docu/tutorials/pb-tutorial.html#A+First+Look+-+Persisting+New+Objects
>
> Did you use the PB-api in the same way?

Apparantly not ;-)

Seriously, I've studied the example you quote before I started coding, but
I interpreted it wrongly. I though I would be save if I requested a
PersistenceBroker only once and then reused it throughout my application
(as long as I used one instance per thread as I learned the hard way ;-).

> Why is it inefficient? Because we use System.arraycopy calls? How many
> active listener do you use between PB lookup and close?

There is no problem if I use the PB api the way you describe. I will fix
my application to close the broker after use and reopen an new one when
needed. This will probably even simplify my code because I do not need
ThreadLocal variables to keep track of a single PersistenceBroker object
per thread anymore.

Thanks for the tip and thanks for a great product! OJB has saved me
hundreds of hours of development time and helped me eradicate almost all
traces of SQL from my application ;-)

Regards,
Pieter.




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

Reply via email to