I have a problem with a custom logging class created for use with my JSP's.  

I am using a factory method from my custom Java class to create log entries via 
a Cayenne entity.  The factory methods create a log entry and immediately 
commit changes to the ThreadObjectContext.  This works fine, except that in 
some error conditions, I might want to rollback changes (as well as log the 
exceptional condition).

So if I log the exceptional condition using the ThreadObjectContext, it appears 
that I will subvert the subsequent rollback for that same exceptional condition 
(i.e. I won't be able to rollback changes).

So I thought that a child context might be handy.  However, I can't figure out 
how to properly manage the scope in a JSP/Library situation.  For example: it 
is easy to get the ThreadObjectContext for a library, and it is easy to create 
a child context, but then you would be creating a child context for every 
INSERT (which the Cayenne docs discourage).

Then, I was considering managing my own singleton to store this child context, 
but this could get complicated with the ThreadObjectContext. So before I did 
this I thought I would ask if Cayenne has a more standard approach.

Thanks,
Joe

Reply via email to