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 Armin Waibel <ar...@apache.org> on 2004/09/01 18:53:46 UTC
Re: OJB and EJB best practices
Hi,
Juerg_Staub@rcomext.com wrote:
> I have some general questions concerning the usage of OJB (odmg) inside
> stateless session beans:
>
> How many databases should I create. The examples session bean contains one
> db instance per bean. Can I share one db instance (OJBJ2EE_2.getInstance
> ().newDabase()) across multiple EJBs?
>
yep, but each Implementation instance could only manage one Database at
same time. When using multiple DB at same time you should use one
Implementation/Database instance per database, e.g. bind to JNDI and
lookup via
> We are facing problems whan rolling back transactions. Even when I call
> setRollbackOnly on the session context, some entries do still make it into
> the database. This is pretty wierd.
>
I have same problems when using JBoss (seems that the
Synchronization#afterCompletion will not be called, OJB use this method
to sync cache and reset PB).
Please try to throw an EJBException instead (fix problem with JBoss).
> Another problem is that when I want to store a new object tree into the db
> and need to query for the exsiting tree on the db (via newOQLQuery()), I am
> not able to store my new tree anymore. I do a tx.lock(newTree,
> Transaction.WRITE), but when turning on tracing I see in the SQL that OBJ
> stores the tree I fetched from the DB.
>
Could you explain more detailed, pseudo code?
regards,
Armin
>
> Our environment is Websphere V5, DB2, obj-1.0.rc6
>
> Thanks
>
> Jürg
>
>
>
>
>
>
> This e-mail, including attachments, is intended for the person(s) or
> company named and may contain confidential and/or legally privileged
> information. Unauthorized disclosure, copying or use of this information
> may be unlawful and is prohibited. If you are not the intended recipient,
> please delete this message and notify the sender
>
>
>
>
> ---------------------------------------------------------------------
> 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
Re: OJB and EJB best practices
Posted by Juerg Staub <Ju...@rcomext.com>.
Armin,
> Could you explain more detailed, pseudo code?
public void storeOption(Option newOption) {
OQLQuery query = this.odmg.newOQLQuery();
Option currentOption = null;
// Query current option for comparison
try {
query.create("select object from " + option.class.getName() + " where
id=" + newOption.getId().intValue());
currentOption = (Option)((List) query.execute()).get(0);
}
NarrowTransaction narrowTx = (NarrowTransaction)
this.odmg.currentTransaction();
// This code makes the currentOption persistent and not the newOption
tx.lock(newOption, Transaction.WRITE);
((TransactionExt) tx).markDirty(o);
}
I verified the SQL statements and I see that really the currentOption is
stored back into the database!
Furthermore we do sporadically get quite many LockNotGrantedExceptions when
doing the tx.lock. I have no explanation why. How can I find out?
Thanks a lot
Juerg
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org