----- Original Message -----
Sent: Friday, January 02, 2004 5:06
AM
Subject: Re: [castor-dev] update in one
transaction
Hi Werner,
Maybe I didn't exactly tell what I
mean.
I have a true case here:
Table "MMM" is the master table and table "DDD"
is the detail table.
There is a field named "detailstatus" on
"DDD".
Also, there is a field named "masterstatus"
on "MMM".
They can all have two values, one is "0", the
other is "1".
The initial values are all 0.
The logic is like this:
Every time I change a "DDD"
record's "detailstatus" from 0 to 1.
Just after this operation, I check its
master record's all detail records(including the record which I just
operated)
to see whether all the
"detailstatus" equals to 1. If this is true, I will change the
"masterstatus" from 0 to 1.
With JDBC, I can use sql "update DDD set
detailstatus = 1 where dddid = XXX",
then "select count(*) cnt from DDD where mmmid
= XXXX and detailstatus <> 1" to get what I need.
But with Castor JDO, I can only use the
setDetailstatus(1) to change the value.
Actually, this has done nothing on
the DATABASE.
So the following OQL "select t from DDD t where
t.detailstatus <> 1" will give me wrong result, except I call commit()
before the OQL.
Obviously, using two transactions may cause
problems.
So, I think there may have defect when
update in one transaction for one cannot get the changed value using
OQL.
Thanks,
Roger
----- Original Message -----
Sent: Friday, December 12, 2003 8:50
PM
Subject: Re: [castor-dev] update in one
transaction
Roger,
looking at the code fragment below, everything
looks fine to me. In order to have a more thorough look at your problem, can
you please post the relevatn parts of your mapping file and the SQL schema
if possible.
Ideally, it would be very nice if you coul�d wrap up
everything with an Ant build file, and transform the below code fragment to
a JUnit test case.
Werner
I am a bit surprised to see that
--Original Message Text---
From: ����
Date: Thu, 11 Dec
2003 15:53:58 +0800
Hi all,
Please see the code:
Database db = JdoUtils.createJdoDb();
db.begin();
Student student =
(Student)db.load(Student.class, new Long(1000));
student.setPassed(1);//the original value was 0
//here, I do
not commit;
OQLQuery
oql = db.getOQLQuery("select s from Student where s.passed = 0 and
s.studentid = 1000");
results = oql.execute();
if
(results.hasMore()){//It will have true value and I can still get the
Student, BUT the value of field "passed" has become 1
System.out.println("there is an error.");
}
else{
//other data
operation
}
db.commit();
db.close();
This is a
common problem which brings me big trouble.
Is this a bug? Or can I have
alternative code?
Thanks,
Roger