[Contrib: Evaluation System] Wrapping a method call in a Hibernate transaction/session?

Jim Eng jimeng at umich.edu
Thu Feb 11 08:23:03 PST 2010


Hi Aaron,

I'm back with another question about hibernate session management.   
The context is pretty much the same as the last two times I asked  
about this.  I'm in a plain vanilla HttpServlet.  I have available  
these EVALSYS singletons:

     - EvalEvaluationSetupService
     - EvalEvaluationService
     - EvalAuthoringService

Each of these is accessed through its own  
"org 
.springframework.transaction.interceptor.TransactionProxyFactoryBean"  
with the injected value for "transactionManager" a reference to  
"org 
.sakaiproject 
.springframework.orm.hibernate.GlobalTransactionManager".  I thought  
would mean that my calls to the EVALSYS component would be in  
hibernate session/transactions, but I am still getting errors when I  
try to save an entity that contains a reference to another existing  
entity.  The exception says there is no hibernate session.

I'm wondering whether I should be using the EvalDaoInvoker to wrap  
everything related to my attempt to save an entity.  We do not want to  
rollback all "create" and "update" actions because one fails, which  
suggests we want transactions at the level of a particular entity.   
Suppose I have a method to extract an EvalItem from an XML element and  
save it. The method attempts to retrieve an existing EvalItem and  
update it.  If none is found, the method creates a new EvalItem and  
attempts to save it. If the XML element provides an EID for an  
EvalScale, the method retrieves the EvalScale and adds it to the java  
object representing the EvalItem before saving the EvalItem.  I think  
I need to wrap that entire process in a transaction.  Does that make  
sense?

 From your experience, does it seem like I might need to make explicit  
use of the EvalDaoInvoker to accomplish that?  If so, is the way  
that's done in the inferDefaultViewParameters() method of the  
EvaluationVPInferrer class a good example of how it might be done?

https://source.sakaiproject.org/contrib/evaluation/trunk/tool/src/java/org/sakaiproject/evaluation/tool/inferrers/EvaluationVPInferrer.java

It's probably been a while since you've worked on this, so sorry to be  
pressing you for ideas.  I hope some part of this might ring a bell  
that might help me.  I've been digging through various docs related to  
Hibernate transactions and such, but in Sakai most of what we do with  
hibernate is several layers removed from the code I'm working on, so  
I'm not sure how to get any control over what I need to without  
upsetting other parts of the system.

Suggestions welcome.

Thanks.

Jim

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/evaluation/attachments/20100211/dd3ce46a/attachment.html 


More information about the evaluation mailing list