spring-transactions

CreateQuery is not valid without active transaction

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-30 09:40:16
问题 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

The Old “@Transactional from within the same class” Situation

送分小仙女□ 提交于 2019-12-29 04:44:06
问题 Synopsis of the original question: Using standard Spring Transactions with AOP proxying, it is not possible to call an @Transactional-marked method from a non-@Transactional-marked method in the same class and be within a transaction (specifically due to the aforementioned proxy). This is supposedly possible with Spring Transactions in AspectJ mode, but how is it done? Edit: The full rundown for Spring Transactions in AspectJ mode using Load-Time Weaving: Add the following to META-INF/spring

Transaction Synchronization in Spring Kafka

醉酒当歌 提交于 2019-12-29 03:23:06
问题 I want to synchronize a kafka transaction with a repository transaction: @Transactional public void syncTransaction(){ myRepository.save(someObject) kafkaTemplate.send(someEvent) } Since the merge (https://github.com/spring-projects/spring-kafka/issues/373) and according to the doc this is possible. Nevertheless i have problems to understand and implement that feature. Looking at the example in https://docs.spring.io/spring-kafka/reference/htmlsingle/#_transaction_synchronization I have to

Spring Transactions and hibernate.current_session_context_class

▼魔方 西西 提交于 2019-12-27 14:42:31
问题 I have a Spring 3.2 application that uses Hibernate 4 and Spring Transactions. All the methods were working great and I could access correctly the database to save or retrieve entities. Then, I introduced some multithreading, and since each thread was accessing to db I was getting the following error from Hibernate: org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions I read from the web that I've to add <prop key="hibernate.current_session

Why is @Transactional(Propagation.NOT_SUPPORTED) not working as expected?

ⅰ亾dé卋堺 提交于 2019-12-25 12:30:11
问题 Given the following: An integration test is started using @Transactional(Propagation.REQUIRED) at class level. Some reference data is inserted with Propagation.NOT_SUPPORTED specified at method level. A service method marked as @Transactional(Propagation.REQUIRED) attempts to look up some reference data inserted in step 2. The service method can't see the reference data! My understanding was that if data is inserted outside the transaction, it would be instantly accessible to another method

Transaction propagation SUPPORTS leads to “HHH000326: Cannot join transaction” warning

断了今生、忘了曾经 提交于 2019-12-25 04:28:16
问题 We are using JPA (Hibernate 4) with Spring 4 managing the JTA transactions. To allow lazy initialization even when simply reading from the database without any transaction we added the "OpenEntityManager" pattern. However with this pattern active, Spring tries to join the already open entity manager to a SUPPORTS transaction as well ( EntityManagerFactoryUtils.doGetTransactionalEntityManager ). Hibernate however denies this request with a (somehow misleading) warning: WARN: HHH000326: Cannot

Spring @Transactional not starting a transaction

戏子无情 提交于 2019-12-25 01:32:58
问题 I have a multi-module Maven project with the following structure: project | -- data | -- DepartmentRepository.java | -- domain | -- Department.java | -- service | -- DepartmentService.java | -- DepartmentServiceImpl.java | -- web | -- DepartmentController.java The project uses Spring 4.1.4, Spring Data JPA 1.7.2 and Maven 3.1.0. The following classes are included: @Entity class Department {} interface DepartmentRepository extends JpaRepository<Department, Long> {} interface DepartmentService

How to enable transaction management in spring application running on multiple JVMs

混江龙づ霸主 提交于 2019-12-25 00:58:28
问题 I have started using Spring framework from last few months. I have a question on how the transaction manager works in the below scenario. Scenario : I'm working on a spring batch in which the ItemReader calls the below method multiple times. This method fetches the list of records from the 'STUDENTS' table which are in status 'NOT COMPLETED' and updates the status of these records to 'IN PROGRESS'. I'm processing 10 million records hence I'm planning to execute my batch process using multiple

delaying identity-insert due to no transaction in progress

泪湿孤枕 提交于 2019-12-25 00:09:14
问题 use Service layer to persist data into database. But the Unit Test does not have this problem. I turn on debug and check the log file carefully. In the place where data should inert into database, I find the information: "delaying identity-insert due to no transaction in progress" 回答1: the issue was due to @Transaction and @Autowire my generic dao was autowired and when we @Transaction it is unable to wrap my service class by transaction proxy class thus .It executes without saving data and

What precisely means setSessionTransacted in JMSTemplate?

半世苍凉 提交于 2019-12-24 18:18:10
问题 Please explain me if I understood correctly Spring documentation. Spring docs states: https://docs.spring.io/spring/docs/current/spring-framework-reference/integration.html#jms-tx (...)When you use the JmsTemplate in an unmanaged environment, you can specify these values ( transaction and acknowledgment modes ) through the use of the properties sessionTransacted and sessionAcknowledgeMode. When you use a PlatformTransactionManager with JmsTemplate, the template is always given a transactional