Hi to all.

I eventually solved the problem by adding a clearCache() after storing the
object in the database. Still, I don't know what happened. Is this normal
behavior ?

-----Message d'origine-----
De : Patrick Prodhon [mailto:[EMAIL PROTECTED]
Envoyé : jeudi 3 avril 2003 17:53
À : Ojb (E-mail)
Objet : Problem with SELECT - UPDATE - SELECT cycle


Hello.

We're using OJB 0.9.7 and I am facing a weird error.
I'm selecting data from one table, joining it on a second table using an
inner join and retrieving one column from the second table. So I use a
Criteria, and type something like "criteria.addEqualTo("joinTable.col",
"somevalue");", as well as "criteria.addNotNull("joinTable.col");",
depending on whether I need to filter on joinTable.col or get all results
satisfying the join.
This done, I retrieve a list of results, and I choose to update one of the
results and the store it using broker.store().
And here comes the trouble : when I re-run my select, and when it gets to
the element I have updated, well I realize that there's no result
corresponding to the second table : the object stored in the first table's
object is null.
Here's some pseudo-code to help understand :

criteria.addNotNull("joinTable.col");
iterator = broker.getIteratorByQuery(QueryFactory.newQuery(Table1.class,
criteria));
// iterate over the iterator
...
table1 = (Table1) iterator.next();
if (table1.getKey().equals("XXX")) {
  // modify
  ...
  // store after beginning transaction (actually, it is not table1 himself
that is stored : copy(copy)...
  broker.store(table1);
  broker.commitTransaction();
}
// Another go
iterator = broker.getIteratorByQuery(QueryFactory.newQuery(Table1.class,
criteria));
// iterate again
table1 = (Table1) iterator.next();
if (table1.getKey().equals("XXX")) {
  table1.getJoinTable().setSomeColumn("Some data"); // raises
NullPointerException for table1.getJoinTable() == null
}

Basically, it seems that I can't retrieve the joined table object associated
with the object that has just been updated.

Has anyone ever encountered this problem ? Has anyone got a clue of where
the problem could be ?

Thanks.
Patrick.


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