no transaction in progress

Added by Jan Verstuyft 5 months ago

Hi Oliver,

I've watched your presentation on Devoxx this year and I want to use it.

I'm pretty new at Spring also, but I've managed to get it al working. I only have a problem for the storing of the data.
Whenever I do a flush, I've got the exception "no transaction is in progress" (see error trace below).

I've added the configuration files. For the record, it is running against a Mysql database (just downloaded from the website).

Kind regards

Jan Verstuyft

Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress
    at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:301)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:358)
    at $Proxy20.flush(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:198)
    at $Proxy20.flush(Unknown Source)
    at org.synyx.hades.dao.orm.GenericJpaDao.flush(GenericJpaDao.java:251)

TestHades.java - client code (761 Bytes)

applicationContext.xml - application context (569 Bytes)

infrastructure.xml - infrastructure (1.6 KB)

persistence.xml (1 KB)


Replies

RE: no transaction in progress - Added by Oliver Gierke 4 months ago

Hey Jan,

sorry for the late reply :). Actually Hades does not make any assumption about transactions itself. So you either have to manage them yourself or better stick to e.g. Spring transaction facilities (by annotating the client using Hades DAOs with @Transactional). For further information see Spring's reference documentation on transactions.

Regards,
Ollie

RE: no transaction in progress - Added by Jan Verstuyft 4 months ago

Hey Oliver,

thanks a lot. Now I know what I was doing wrong :).
You can only use the @Transactional on something that you are proxying on (like the beans). In my example, I had the plain object TestHades and that didn't work.

Thanks for the reply.

Jan