Hello,
I have a question/problem about the function getIteratorByQuery():
Here is a code:
****code****
Iterator iter = null;
try {
broker = PersistenceBrokerFactory.defaultPersistenceBroker();
broker.beginTransaction();
iter = broker.getIteratorByQuery(query);
broker.commitTransaction();
} catch (PersistenceBrokerException t) {
broker.abortTransaction();
t.printStackTrace();
} finally {
broker.close();
}
while (iter.hasNext()) {
Person person = (Person) iter.next();
....
some code
....
}
****code****
I have noticed that the Iterator object called iter isn't available after the broker
is closed (no iteration in the "while" statement).
Why?
My idea is to use a broker only when I need one and close it just after the use.
What is the solution?
But could I write the code as below?
****code****
try {
broker = PersistenceBrokerFactory.defaultPersistenceBroker();
broker.beginTransaction();
Iterator iter = broker.getIteratorByQuery(query);
while (iter.hasNext()) {
Person person = (Person) iter.next();
....
some code
....
}
broker.commitTransaction();
} catch (PersistenceBrokerException t) {
broker.abortTransaction();
t.printStackTrace();
} finally {
broker.close();
}
****code****
Thanks for any help
Sylvain
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]