FAQ Database Discussion Community


Spring Datasource transaction manager: transactionality across multiple instances of an application

java,spring,scala,transactions,spring-transactions
Given all of the DB operations I'm performing on an Oracle datasource (using JDBCTemplate) are executed using a transaction template that uses a Spring Datasource TransactionManager, If multiple copies of my application receive requests to perform database operations on the same datasource, will the operations still be transactional? If another...

Spring Transaction or Hibernate Transaction

spring,hibernate,spring-mvc,transactions,spring-transactions
I am aware that I am posting a redundant question. I've gone through various posts in SO and other blogs too, but I've required bit more clarity on couple more items & so posting here. I use Spring + Hibernate. I am inserting some 'n' records. MySpringController.java @Transactional @RequestMapping(...) public...

Transaction with binded thread connection in Spring

spring,jdbc,transactions,spring-transactions
I want to bind a connection to a thread, and use that connection for any JdbcTemplate calls, to finally commit the changes or do a rollback. I'm declaring all sentences from a Groovy script, so I can't control how many SQL query will be call, that's why I have to...

LazyInitializationException: failed to lazily initialize a collection of role could not initialize proxy - no Session

spring,hibernate,spring-mvc,spring-transactions
This is asked many times in SO. But they didn't solve my issue so posting again. Getting following exception while trying to access my application org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.wpt.models.Item.itemCategory, could not initialize proxy - no Session at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:575) at...

Spring Data JPA Transaction - No Transaction in progress - Spring Data Neo4j

spring,spring-boot,spring-data,spring-data-jpa,spring-transactions
I think i'm missing something obvious. Iam trying to make a entity persist into a database via a JUnit Test case, however it doesnt seem to be persisting due to no active transaction. Configuration: @Configuration @EnableTransactionManagement public class TransactionConfig { @Inject private EntityManagerFactory entityMangerFactory; @Bean public JpaTransactionManager transactionManager(){ return new...

Multiple transaction managers - Selecting a one at runtime - Spring

java,spring,transactions,spring-transactions
I am using Spring to configure transactions in my application. I have two transaction managers defined for two RabbitMQ servers. .... @Bean(name = "devtxManager") public PlatformTransactionManager devtxManager() { return new RabbitTransactionManager(devConnectionFactory()); } @Bean(name = "qatxManager") public PlatformTransactionManager qatxManager() { return new RabbitTransactionManager(qaConnectionFactory()); } @Bean public ConnectionFactory devConnectionFactory() { CachingConnectionFactory factory...

Spring @Transactional not committing records

spring,hibernate,spring-transactions
I use Spring with Hibernate. I am using following configurations. When I try to save through Spring transaction, the record never commits. <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation=" http://www.springframework.org/schema/beans...

Spring app - run method on end of transaction?

java,spring,spring-mvc,spring-transactions
I wondering it is possible to configure spring in way to fire particular method on end transaction? For example I have service class with method @Service public class service implements IService { @Resource private EntityDao entityDao; @Resource private SomeService someService; @Transactional @Override public void doThings() { entityDao.doSmthOnDb(); someService.thisMethodFiresOnEndOfTransaction(); } }...

AspectJ not working after Transaction configuration in Spring Boot

spring,spring-boot,aspectj,spring-transactions
Firstly i had a problem with Transactions not working so i updated the configutation from @EnableTransactionManagement to @EnableTransactionManagement(proxyTargetClass=true), but after the update this bug is thrown at launch. after commenting all code related to AspectJ, the bugs disappears and the transaction is working perfectly, but i'm missing my AspectJ functions....

Reading from a JDBC Blob after leaving the Spring transaction

jax-rs,blob,spring-transactions
I have the following schematic implementation of a JAX-RS service endpoint: @GET @Path("...") @Transactional public Response download() { java.sql.Blob blob = findBlob(...); return Response.ok(blob.getBinaryStream()).build(); } Invoking the JAX-RS endpoint will fetch a Blob from the database (through JPA) and stream the result back to the HTTP client. The purpose of...

ApsectJ is throwing exception while adding @Transactional annotation

java,spring,aop,aspectj,spring-transactions
We are using AOP and everything works fine, I have added @Transactional. This is happening when i move from one method to another and i can't find any connection!! !!!! annotation and the application is not starting and throwing exception: Reason: Expected stackmap frame at this location. Bytecode: 0000000: 014e...

Is spring transaction is only working in entering service method?

mysql,spring,transactions,spring-transactions
I have read many stackoverflow's pages about spring transaction. My spring transaction config is <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/> My service is like this. @Service public class TestServiceImpl implements TestService { @Override public void testRollback() { testRollbackSecondLevel(); } @Transactional @Override public void testRollbackSecondLevel() { // any update sql in here carCostService.testUpdate(); throw...

If my value is stored in a Thread Safe map does the value need to be ThreadLocal?

java,multithreading,spring,spring-transactions
I'm storing objects in a ThreadLocal Map ( implemented in spring-tx) class TransactionSynchronizationManager ... private static final ThreadLocal<Map<Object, Object>> resources = new NamedThreadLocal<Map<Object, Object>>("Transactional resources"); if the Map is ThreadLocal and properly accessed (again all spring-tx code), do the values I store in the map have to be ThreadLocal to...

Does JTA support Clustering of application servers?

transactions,jta,spring-transactions,transactional,distributed-transactions
I have successfully implemented JTA over multiple databases at different location;commit and rollback. All i need to know is if i could work with different application servers? Will clustering of different application server will be supported by JPA? also if there are any databases where it cannot be implemented(other then...