Hi, Armin
Thank you very much for the fixing. But I have one
more question. If the batch mode is turned on by
calling
broker.getConnectionManager().setBatchMode("true"), db
operations will not be applied to
db until transaction is commited. In this case, I will
still have the problem if I want to insert two records
in a batch and then retrieve them back right away
without committing the transaction. This looks
differen from JDBC. After
PreparedStatement.executeBatch, even the transaction
is not commited, I believe I can still retrieve them
back. Is there any paticular reason for the OJB batch
mode implementation?
Thanks,
Zhe
> -----Original Message-----
> From: Armin Waibel [mailto:[EMAIL PROTECTED]
> Sent: Sunday, January 18, 2004 8:57 AM
> To: OJB Users List
> Subject: Re: FW: Cannot retrieve back just saved
> objects without
> committing transaction
>
>
> Hi Zhe,
>
> I add your test case to test suite and fix the
> problem in CVS head. It
> will be included in upcoming 1.0.
> You can easy fix it by changing one line in
> ConnectionManagerImpl - see
> below.
>
> Thank you very much for test case and detailed
> description.
>
> regards,
> Armin
>
>
> RCS file:
>
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManage
> rImpl.java,v
> retrieving revision 1.9
> retrieving revision 1.10
> diff -u -r1.9 -r1.10
> --- ConnectionManagerImpl.java 2 Nov 2003
> 13:21:08 -0000 1.9
> +++ ConnectionManagerImpl.java 18 Jan 2004
> 16:47:35 -0000 1.10
> @@ -101,7 +101,14 @@
> this.jcd =
>
MetadataManager.getInstance().connectionRepository().getDescriptor(pbKey);
> this.connectionFactory =
>
ConnectionFactoryFactory.getInstance().createConnectionFactory();
> this.platform =
> PlatformFactory.getPlatformFor(jcd);
> - setBatchMode(this.jcd.getBatchMode());
> + /*
> + by default batch mode is not enabled and
> after use of a PB
> + instance, before instance was returned
> to pool, batch mode
> + was set to false again (PB
> implementation close method)
> + Be carefully in modify this behaviour,
> changes could cause
> + unexpected behaviour
> + */
> + setBatchMode(false);
> }
>
>
>
> ZZZ Liu wrote:
> > It is a standalone program and the database is
> Oracle.
> >
> > Here is the sample code:
> >
> > Product product = new Product();
> > product.setProductCode("AAA");
> > product.setDesc("BBB");
> >
> > PersistenceBroker broker = null;
> > try
> > {
> > broker =
> >
> PersistenceBrokerFactory.defaultPersistenceBroker();
> > broker.beginTransaction();
> > // assuming "AAA" is a new record that does
> not
> > exist in database
> > broker.store(product,
> > ObjectModificationDefaultImpl.INSERT);
> >
> > Query query = new
> QueryByCriteria(Product.class,
> > null);
> > Collection all =
> > broker.getCollectionByQuery(query);
> > Iterator iter = all.iterator();
> > while (iter.hasNext())
> > {
> > // "AAA" will not be printed
> > System.out.println(iter.next());
> > }
> > broker.commitTransaction();
> > }
> > catch (Throwable t)
> > {
> > broker.abortTransaction();
> > t.printStackTrace();
> > }
> > finally
> > {
> > try
> > {
> > broker.close();
> > }
> > catch (Exception e)
> > {
> > }
> > }
> > // "AAA" will be in database after the program
> > finishes.
> >
> > Thanks,
> > Zhe
> >
> > -----Original Message-----
> > From: Armin Waibel [mailto:[EMAIL PROTECTED]
> > Sent: Friday, January 16, 2004 12:53 AM
> > To: OJB Users List
> > Subject: Re: FW: Cannot retrieve back just saved
> > objects without
> > committing transaction
> >
> >
> > Hi Zhe,
> >
> > ZZZ Liu wrote:
> >
> >
> >>Hi, Armin
> >>
> >>Thanks a lot for your reply. I am using PB-api and
> >
> > the
> >
> >>batch mode is turned on (in
> repository_database.xml,
> >>batch-mode="true" for jdbc-connection-descriptor).
> I
> >>found that database operations are not applied to
> db
> >>until transaction is commited. For example, if I
> try
> >>to insert null into a "not null" field, I won't
> get
> >>exception until transaction is commited. Is the
> >>problem caused due to batch-mode=true?
> >>
> >
> >
> > hmm, set batch-mode 'true' enables OJB to use
> batch
> > operations if your
> > DB supports it. But you have to call
> > broker.getConnectionManager().setBatchMode("true")
> > before begin with
> > pb-tx to start a batchable session. If you do so,
> then
> > the answer is yes.
> >
> > I assume your problem is another. Are you sure
> that
> > you always use the
> > same PB instance?
> > What's the environment - servlet, stand-alone,
> > managed-environment?
> > Can you post your sample code?
> >
> > regards,
> > Armin
> >
> >
> >>Thanks,
> >>Zhe
> >>
> >>
> >>
__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]