spring-transactions

No transactional EntityManager available

人走茶凉 提交于 2019-12-01 06:14:31
I am new to the jpa and spring world and I am currently doing some unit test on a simple method but keep getting this error message only when I run my test class in unit test mode: java.lang.IllegalStateException: No transactional EntityManager available at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:223) at $Proxy19.unwrap(Unknown Source) at com.gemstone.integration.PersonDao.getPersonByUserNamePassword(PersonDao.java:59) at com.gemstone.integration.PersonDaoTest.getPersonByUserNamePassword_Exist

CreateQuery is not valid without active transaction

我是研究僧i 提交于 2019-12-01 05:27:07
I'm trying to use the Spring @Transactional annotation, but i have problems when the method findAll is called and i have this error: org.hibernate.HibernateException: createQuery is not valid without active transaction at org.hibernate.context.internal.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:352) at com.sun.proxy.$Proxy57.createQuery(Unknown Source) at org.munaycoop.taskmanager.daos.PersonDataAccesObject.findAll(PersonDataAccesObject.java:20) at org.munaycoop.taskmanager.services.PersonService.findAll(PersonService.java:26) at org.munaycoop

Setting Up Annotation Driven Transactions in Spring in @Configuration Class

爱⌒轻易说出口 提交于 2019-12-01 02:27:40
So in the latest version of Spring we are able to use the @Configuration annotation to setup our configurations for Spring. Now in JavaConfig it is possible to use the @AnnotationDrivenTx ( @AnnotationDrivenTx Reference Link) annotation to setup transactions in our Config class. But since JavaConfig has been decommissioned I was wondering if anyone knew how to setup something similar without JavaConfig and without needing to add anything to the application-context.xml . Here is what I basically have for my Config class @Configuration @ImportResource("config/application-context.xml") public

Spring @Transactional Annotation properties precedence / inheritance

点点圈 提交于 2019-12-01 01:27:56
问题 In the case of REQUIRED propagation when the caller method itself is transactionnal does the current method overrides enclosing transaction properties (for example rollbackFor) if they are different ? illustration : Class A { @Transactional(propagation = Propagation.REQUIRED, rollbackFor = { SomeException.class}) void foo() { try { b.bar(); } catch (OtherException e) { // is the transaction marked as rollback-only at this point ? } } } Class B { @Transactional(propagation = Propagation

Setting Up Annotation Driven Transactions in Spring in @Configuration Class

一笑奈何 提交于 2019-11-30 21:57:02
问题 So in the latest version of Spring we are able to use the @Configuration annotation to setup our configurations for Spring. Now in JavaConfig it is possible to use the @AnnotationDrivenTx (@AnnotationDrivenTx Reference Link) annotation to setup transactions in our Config class. But since JavaConfig has been decommissioned I was wondering if anyone knew how to setup something similar without JavaConfig and without needing to add anything to the application-context.xml . Here is what I

java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool

最后都变了- 提交于 2019-11-30 20:26:52
I'm trying to configure org.apache.commons.dbcp.BasicDataSource as bean in web.xml under a tomcat project using tomcat 6 and postgresql 9.1 my servletdispacher.xml ` <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="org.postgresql.Driver" /> <property name="url" value="jdbc:postgresql://localhost:5432/car" /> <property name="username" value="postgres" /> <property name=

Spring and Hibernate suddenly set the transaction to readonly

牧云@^-^@ 提交于 2019-11-30 17:44:59
We have an application running on JBoss 4.2.3, using Spring 2.5.2 and Hibernate 3.2.6.ga. This is running on Linux JEE01 2.6.16.60-0.54.5-smp, using its own user. Writing to a Oracle 10G database on another machine. We're using a standard view -> service -> dao layering. Where each dao is annotated with @Repository. This is all running 24/7 without many problems, but every several days and sometimes a couple of times in one day the whole system goes into a bad state where nothing can be written to the database anymore. These stacktraces appear in the logs: org.springframework.dao

java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool

不羁的心 提交于 2019-11-30 17:00:08
问题 I'm trying to configure org.apache.commons.dbcp.BasicDataSource as bean in web.xml under a tomcat project using tomcat 6 and postgresql 9.1 my servletdispacher.xml ` <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="org.postgresql.Driver" /> <property name="url" value=

Difference between JTA and Spring @Transactional annotations

走远了吗. 提交于 2019-11-30 15:07:55
问题 I've been starting to use Spring's @Transactional annotation, and it provides a lot of convenience for managing transactions. However, using this annotation in our code now makes us dependent on Spring. I know with JPA type stuff there is a javax persistence package where we can mark up the code with all sorts if JPA annotations, but since they all come from javax.persistence , our code isn't dependent on any specific implementation or ORM. I guess my question is if there are any similar

Transaction management with Spring Batch

主宰稳场 提交于 2019-11-30 12:19:58
问题 I am discovering actually Spring and I am able to setup some jobs. Now, I would like to save my imported datas in a database using Hibernate/JPA and I keep getting this error : 14:46:43.500 [main] ERROR o.s.b.core.step.AbstractStep - Encountered an error executing the step javax.persistence.TransactionRequiredException: no transaction is in progress I see that the problem is with the transaction. Here is my spring java config for the entityManager and the transactionManager : @Configuration