Hi,
I am trying to set up an error page in my web application that sends
error
details to me. I can easily get the stack trace and other variables but
I can't the heck find out how to get the last query cayenne has
executed.
So far, I have managed to set up a DataContextDelegate that is called
for
every query but I cannot get it to store some valuable info from the
current
query.
What I want is to retrieve similar information as to what the
QueryLogger
writes into the log.
> INFO QueryLogger: SELECT t0.SOMPR1, t0.SOMPR2, t0.SOM .. [bind....]
Is that possible?
Or is there an even easier way to retrieve information about the querie
at the place where the SQLException is thrown by accessing the exception
itself?
Thanks,
Andreas Pardeike
Here's my DataContextDelegate code in my global application object:
> dataContext = DataContext.createDataContext();
> dataContextDelegate = new DataContextDelegate()
> {
> public void finishedMergeChanges(DataObject object) {}
> public void finishedProcessDelete(DataObject object) {}
> public boolean shouldProcessDelete(DataObject object) { return
> true; }
> public boolean shouldMergeChanges(DataObject object, DataRow
> snapshotInStore) { return true; }
>
> private void store(String type, DataContext c, Query q)
> {
> // TODO - get and store info about the current query
> // so it can be fetched later at the exception
> displaying page
> }
>
> public org.objectstyle.cayenne.query.GenericSelectQuery
> willPerformSelect(DataContext context,
> org.objectstyle.cayenne.query.GenericSelectQuery query)
> {
> store("GenericSelectQuery", context, query);
> lastQuery = query;
> return query;
> }
>
> public Query willPerformQuery(DataContext context, Query query)
> {
> store("Query", context, query);
> lastQuery = query;
> return query;
> }
>
> public Query willPerformGenericQuery(DataContext context, Query
> query)
> {
> store("GenericQuery", context, query);
> lastQuery = query;
> return query;
> }
> };
>
> dataContext.setDelegate(dataContextDelegate);
This archive was generated by hypermail 2.0.0 : Fri Aug 18 2006 - 08:05:18 EDT