spring-transactions

Log4J configuration not displaying Spring Transaction and other logs in JBoss AS7

不问归期 提交于 2019-12-10 10:56:46
问题 Following is my log4j.properties: log4j.rootLogger=ALL, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d [%t] %p [%c] - %m%n log4j.logger.org.springframework=ALL log4j.logger.app.dev.ems=ALL log4j.logger.org.springframework.transaction=ALL I have mentioned the log4jConfigLocation in the web.xml: <context-param> <param-name

Understanding transaction session with lazy loading in Spring JPA Hibernate

限于喜欢 提交于 2019-12-10 10:14:35
问题 I would like to get some clarification regarding lazy loading and session boundaries etc. My code structure is as follows @Entity class A { .... @OneToOne(fetch=LAZY) private B b; .. } @Entity class B { private id; private name; } @Transactional(SUPPORTS) ADao { A findById(int id); } @Transactional(SUPPORTS) LayerDB { A getAForId(int i) { return adao.findById(i); } } //Note that there is no transactional attribute here LayerB { public boolean doSomethingWithAandB(int aId) { A a = LayerDB

@Async is killing Hibernate transaction

余生长醉 提交于 2019-12-10 09:54:38
问题 I am using an Open-Session-In-View transaction model for my REST api like this: @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) sessionFactory.getCurrentSession().beginTransaction(); chain.doFilter(request, response); sessionFactory.getCurrentSession().getTransaction().commit(); } This work just fine. I wanted to add @Async abilities. So I created: @Configuration @EnableAsync public class AsyncConfig implements AsyncConfigurer { @Override

java.lang.NoClassDefFoundError: org/springframework/transaction/interceptor/TransactionInterceptor Error

断了今生、忘了曾经 提交于 2019-12-10 00:50:25
问题 I'm trying to configure <tx:annotation-driven /> in web.xml under a tomcat project using tomcat 6 and postgresql 9.1 My dispacher-Servlet.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org

Spring Transaction Doesn't Rollback

 ̄綄美尐妖づ 提交于 2019-12-09 18:32:17
问题 We have a Spring Transaction rollback issues, where rollback doesn't seems to be working. Within my service layer method which is annotated with @Transactional I call three different DAOImpl classes to insert 3 records. The middle insert do a get from a 4th table to populate a description field but this get failed. I expect the first insert to rollback but it doesn't seems to be happening. Few Points: The 'Get' method throws a Runtime Exception We are using org.springframework.jdbc.datasource

Spring Jdbc declarative transactions created but not doing anything

五迷三道 提交于 2019-12-09 01:21:43
问题 I have tried to configure declarative transaction management within my Spring-based web application and it refuses to cooperate with me. I have two main problems: Setting defaultAutoCommit to false on our dataSource (which we need for our application) causes all queries to rollback, with or without transactions being involved. Transactions are configured and proxy classes as well as transactional methods are created, however no transactions appear to be used. The first problem is rather

Spring Transactional annotation, isolation not working for READ_UNCOMMITTED

眉间皱痕 提交于 2019-12-08 21:19:24
I have a method in Java which is wrapped by a spring Transactional annotation. I have 2 operations inside, one is delete , another one is insert . My insertion statement have to rely on the first operation (which is the delete ), but now because of the first operation is not committed yet, my insertion fail (unique constraint). But this is funny that, usually within the same transaction, I should be able to read/see the uncommited operation in the same transaction (my old proprietary framework are able to do that), but this is not happening for my scenario, the second insertion still fail

Spring transactions not working + JAX WS + JDBC

眉间皱痕 提交于 2019-12-08 19:32:34
问题 I'm a bit exasperated with this issue. Lets check if someone has implemented something similar. I have a java 8 web application with 8 WS implemented. Some of this WS, make inserts and updates through JDBCTemplate (Hibernate is not a choice due to performance needs) and i need them to rollback if execution crashes with an exception. I have the following configuration of datasource and transaction manager in spring app context file (jndi resource in server.xml/context.xml of Tomcat): <bean id=

Hibernate: LazyInitializationException: failed to lazily initialize a collection of role. Could not initialize proxy - no Session

♀尐吖头ヾ 提交于 2019-12-08 16:21:40
问题 I have next error: nested exception is org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.example.Model.entities, could not initialize proxy - no Session My Model entity: class Model { ... @OneToMany(fetch = FetchType.LAZY, mappedBy = "model", orphanRemoval = true) @Cascade(CascadeType.ALL) @Fetch(value = FetchMode.SUBSELECT) public Set<Entity> getEntities() { return entities; } public void addEntity(Entity entity) { entity.setModel(this);

Spring self injection for transactions

假装没事ソ 提交于 2019-12-08 15:46:41
问题 In Spring you can't simply call @Transactional method from the same instance, because of AOP-proxy thing. Would it be nice idea to make a self injection and call that method from self proxy instance? Do you see any drawbacks? 回答1: It is totally ok. Moreover there was a Jira ticket for supporting this feature using @Autowired annotations. It's fixed in Spring 4.3+ versions. However for xml-based configuration or using @Resource annotation it's working in the earlier versions. You can see the