Hi,
I've a similar problem as
http://archives.apache.org/eyebrowse/ReadMsg?[EMAIL PROTECTED]
e.org&msgNo=4732. I attempt to query a database record that has a collection
attribute (1:N relationship) in OJB, then send it to my remote M$ .NET
client via web service, and allows the client to modify the data, then send
it back to OJB for update. I prefer to use OQL without a read lock to query
(I want a generic query method):
public Collection query(String queryString, int startAtIndex, int
endAtIndex, Object[] parameters) throws ODMGException,
QueryInvalidException, QueryParameterCountInvalidException, QueryException {
EnhancedOQLQuery query = odmg.newOQLQuery();
query.create(queryString, startAtIndex, endAtIndex);
if (parameters != null) for (int i = 0; i < parameters.length; i += 1)
query.bind(parameters[i]);
return (Collection) query.execute();
}
I feel great with the PB API for SELECT and INSERT, but the differences
between the PB API and the ODMG API (as said in the faq page) causes cascade
DELETE (and cascade update's delete) to fail in recursive objects. Is there
any generic way to implement long transaction using only the PB API (ignore
the timestamp issue for now)? For the second transaction of the long
transaction, it's not generic to query the record again using the ODMG API,
and modify the queried object using reflection then commit it! And deleting
all objects in the collection attribute manually, then call PB's store()
doesn't seems to be good as well!
The below generic methods are how my wrapper object is implemented
public Object update(Object data) throws Exception {
Transaction tx = odmg.newTransaction();
tx.begin();
try {
((HasBroker) tx).getBroker().store(data);
tx.commit();
}
catch (Throwable t) {
tx.abort();
throw new Exception(t.getMessage());
}
return data;
}
public void remove(Object data) throws Exception {
Transaction tx = odmg.newTransaction();
tx.begin();
try {
((HasBroker) tx).getBroker().delete(data);
tx.commit();
}
catch (Throwable t) {
tx.abort();
throw new Exception(t.getMessage());
}
}
Thanks
Thomas Phan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]