Spring's @Transactional with Groovy not working

51 views
Skip to first unread message

Scott

unread,
Apr 14, 2011, 2:08:54 PM4/14/11
to Gaelyk
I know this isn't Gaelyk specific, but I am using Gaelyk with Spring
and having some problems...

I obtain a Spring service bean via WebApplicationContextUtils that
does some stuff with the datastore.

The problem I am having is that when my service is a Java file, Spring
honors the @Transactional annotation. But, as soon as I rename my
service bean to .groovy, @Transactional no longer works.

Anyone have any idea why this might be happening?

This is my service method:

@Transactional
public User findUser(Long id) {
if (id == null) return null;
Query query = entityManager().createQuery("SELECT o FROM User
o WHERE o.id = :id").setParameter("id", id);
User result = null;
List results = query.getResultList();
if (results.size() > 0) {
result = (User) results.get(0);
}
return result;
}

Like I said, when it is Java, it works fine, but once it is a groovy
file, I get some sort of session closed exception when it gets to
results.size()

Steven

unread,
Apr 14, 2011, 6:30:13 PM4/14/11
to Gaelyk
I suggest posting this on something like stackoverflow.com

Scott

unread,
Apr 14, 2011, 7:55:31 PM4/14/11
to Gaelyk
Yeah, maybe I will try that. Believe it or not I am actually using
this code with Gaelyk, so I thought I would give it a try here first.
I am building a gaelyk/java hybrid application. It works pretty good
with the exception of not being able to make my service classes
groovy.
Reply all
Reply to author
Forward
0 new messages