Thanks a lot. I will try later. Zhe > > > -----Original Message----- > From: Armin Waibel [mailto:[EMAIL PROTECTED] > Sent: Wednesday, January 21, 2004 12:38 AM > To: OJB Users List > Subject: Re: FW: FW: Cannot retrieve back just saved > objects without > committing transaction > > > Hi Zhe, > > ZZZ Liu wrote: > > 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? > > Works in the same way as pur JDBC. You have to call > PB.serviceConnectionManager.executeBatch() > to execute the batch without committing the tx. > > regards, > Armin > > > > > 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: > === message truncated ===
__________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
