You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Charles Anthony <ch...@hpdsoftware.com> on 2003/07/29 12:53:12 UTC

RE: ojb + struts webapp question

Hi,
1. It is best not to store the broker at all, but to get it each time that
you need it. Seeing as how it is a simple one liner, I don't see how it is
an issue :
PersistenceBroker broker =
PersistenceBrokerFactory.defaultPersistenceBroker();
Note : It is important to close the broker after you have finished using it.
I don't know much (read virtually nothing) about Struts, but maybe you can
put helper methods on a superclass of Action (or Form) get and close the
brOker

2. I believe the best approach is to use the p6spy, as it also logs the
values of the bound values of prepared statements (instead of just '?'s).
Read the FAQ for details : http://db.apache.org/ojb/faq.html

HTH 

Cheers,

Charles.

>-----Original Message-----
>From: Andreas Wuest [mailto:AndreasWuest@gmx.de]
>Sent: 29 July 2003 13:12
>To: ojb-user@db.apache.org
>Subject: ojb + struts webapp question
>
>
>Hi,
>
>i am new to ojb and i'd like to use it in a struts web 
>application. however
>i have some question for best practice :
>
>1. to access the web app the users have to login. after login in i need
>   serveral db accesses on different pages. is it best to store a
>   PersistenceBroker instance in the session (so each logged 
>in user has
>   a broker of its own) or should a i put a PersistenceBroker instance
>   into the application context (all users use the same 
>persistence broker) ?
>   One broker per User is probably the best solution (concerning
>   transactions), isn't it ?
>
>2. is there a way to show the sql statement that the persistence broker
>   is running against to database so i can compare the statement with
>   the sql that i intended to run (just to check if the created sql 
>   is correct).
>
>thanks in advance,
>
> Andreas
>
>   
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>


This email and any attachments are strictly confidential and are intended
solely for the addressee. If you are not the intended recipient you must
not disclose, forward, copy or take any action in reliance on this message
or its attachments. If you have received this email in error please notify
the sender as soon as possible and delete it from your computer systems.
Any views or opinions presented are solely those of the author and do not
necessarily reflect those of HPD Software Limited or its affiliates.

 At present the integrity of email across the internet cannot be guaranteed
and messages sent via this medium are potentially at risk.  All liability
is excluded to the extent permitted by law for any claims arising as a re-
sult of the use of this medium to transmit information by or to 
HPD Software Limited or its affiliates.



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: ojb + struts webapp question

Posted by Andreas Wuest <An...@gmx.de>.
Hi,

thanks for your reply. 

> 1. It is best not to store the broker at all, but to get it each time that
> you need it. Seeing as how it is a simple one liner, I don't see how it is
> an issue :
> PersistenceBroker broker =
> PersistenceBrokerFactory.defaultPersistenceBroker();
> Note : It is important to close the broker after you have finished using
> it. I don't know much (read virtually nothing) about Struts, but maybe you
> can put helper methods on a superclass of Action (or Form) get and close
> the brOker
1. as far as i could see the broker is not serializable, so cannot store in 
    the session anyway.

> 2. I believe the best approach is to use the p6spy, as it also logs the
> values of the bound values of prepared statements (instead of just '?'s).
> Read the FAQ for details : http://db.apache.org/ojb/faq.html

this p6spy thing is really cool. finally i can stop using System.out.println
to debug my sql statements :-)

thanks,

 Andreas


>
> HTH
>
> Cheers,
>
> Charles.
>
> >-----Original Message-----
>
> From: Andreas Wuest [mailto:AndreasWuest@gmx.de]
>
> >Sent: 29 July 2003 13:12
> >To: ojb-user@db.apache.org
> >Subject: ojb + struts webapp question
> >
> >
> >Hi,
> >
> >i am new to ojb and i'd like to use it in a struts web
> >application. however
> >i have some question for best practice :
> >
> >1. to access the web app the users have to login. after login in i need
> >   serveral db accesses on different pages. is it best to store a
> >   PersistenceBroker instance in the session (so each logged
> >in user has
> >   a broker of its own) or should a i put a PersistenceBroker instance
> >   into the application context (all users use the same
> >persistence broker) ?
> >   One broker per User is probably the best solution (concerning
> >   transactions), isn't it ?
> >
> >2. is there a way to show the sql statement that the persistence broker
> >   is running against to database so i can compare the statement with
> >   the sql that i intended to run (just to check if the created sql
> >   is correct).
> >
> >thanks in advance,
> >
> > Andreas
> >
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >For additional commands, e-mail: ojb-user-help@db.apache.org
>
> This email and any attachments are strictly confidential and are intended
> solely for the addressee. If you are not the intended recipient you must
> not disclose, forward, copy or take any action in reliance on this message
> or its attachments. If you have received this email in error please notify
> the sender as soon as possible and delete it from your computer systems.
> Any views or opinions presented are solely those of the author and do not
> necessarily reflect those of HPD Software Limited or its affiliates.
>
>  At present the integrity of email across the internet cannot be guaranteed
> and messages sent via this medium are potentially at risk.  All liability
> is excluded to the extent permitted by law for any claims arising as a re-
> sult of the use of this medium to transmit information by or to
> HPD Software Limited or its affiliates.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org