Hello Satish,
sa...@na... wrote:
>
> Hi again,
>
> I have a few more questions..Any help is greatly
> appreciated..
>
> 1. Querying.. How can do I something as simple as
> getting the max out of a column.
>
> I thought I could use Criteria of orderBy and use
> queryByIterator and get the first one.
Good idea.
> But I dont
> see any descending order on Criteria.orderBy(String).
>
Oops, you are right. I will add a signature Criteria.orderBy(String,
boolean) to signal ascending or descending order.
> 2. Broker and JDBC Connection:
>
> >From what I can see, Broker uses a single Connection object
> for jdbc access for all classes by default.
> I am using a single static instance of
> PersistenceBroker for all the transcations and queries that
> are potentially executed on multiple threads. I notice that
> begin, end and commitTransaction methods are synchronized,
> but query, store, delete methods are not. I guess I will have
> to synchronize access to those methods. Am I right?
>
To use the PersistenceBroker as a singleton instance in a multithreaded
environment is not recommended. The Broker can only handle one
transaction at a time. For instance, If you called PB.beginTransaction()
in one thread you will get a TransactionInProgressException if you call
PB.beginTransaction() in a second thread!
There is no need to synchronize query, store etc. but you have to keep
in mind that ALL operation made after beginTransaction() belong to the
same transaction. (In the above example the operations in thread 1 and 2
belong to the same transaction!
If you need multiple transactions with multiple threads I would suggest
to have a broker instance with each thread. Have a look at
ojb.broker.server where I implemented a multithreaded
PersistenceBrokerServer with multiple Brokers.
HTH
Thomas
> Thanks,
> Satish.
>
> --
> Get your firstname@lastname email for FREE at http://Nameplanet.com/?su
|