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/ConnectionManagerImpl.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



-----Original Message-----
From: Armin Waibel [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 15, 2004 2:25 AM
To: OJB Users List
Subject: Re: Cannot retrieve back just saved objects
without committing
transaction


Hi Zhe,


ZZZ Liu wrote:


Hi, all

I have a problem when I try to insert an object in

a



data base table and then try to retrieve all

records


from that table. I use the same persistence broker

for



the above two operations.
I found that if I don't
commit the transaction after save, the retrieved
records won't include the new record just saved.

If you are using PB-api this should work.
PersistenceBroker has same behaviour as a "pur Connection". If you start a
PB-tx a connection was associated with the PB instance. Do you enable batch
mode?


The ODMG-api is different, it collects all changes
till commit is called. To write changes to DB while the tx is
running, you have to call proprietary TransactionExt#flush() method.


regards,
Armin



I am
wondering whether anybody else ever had this

problem



and whether this is a bug or is designed in this

way.



But I know if I use JDBC directly, and if I insert

a



record in a database table, even though it is not
commited, the record should be visible to current
session (connection).

I am using rc5. Any help or comments on this

problem



would be much appreciated.

Thanks in advance.
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]






---------------------------------------------------------------------

To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]





__________________________________ 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]







--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



__________________________________
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]






--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to