Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is @EnableTransactionManagement XML equivalent in Spring 4?

Tags:

java

spring

What is @EnableTransactionManagement XML equivalent in Spring 4?

BTW, as newbie in Spring, I have no idea where to look such XML equivalents for other annotations.

like image 793
Andremoniy Avatar asked Apr 05 '16 08:04

Andremoniy


People also ask

What is the use of @EnableTransactionManagement annotation?

Annotation Type EnableTransactionManagement. Enables Spring's annotation-driven transaction management capability, similar to the support found in Spring's <tx:*> XML namespace. To be used on @Configuration classes to configure traditional, imperative transaction management or reactive transaction management.

Does spring still use XML?

Spring 3.0 introduced JavaConfig, allowing us to configure beans using Java classes. However, XML configuration files are still used today. In this tutorial, we'll discuss how to integrate XML configurations into Spring Boot.

What is @transactional in spring boot?

The @Transactional annotation is metadata that specifies that an interface, class, or method must have transactional semantics; for example, "start a brand new read-only transaction when this method is invoked, suspending any existing transaction".

What is @transactional used for?

The @Transactional annotation is the metadata that specifies the semantics of the transactions on a method. We have two ways to rollback a transaction: declarative and programmatic. In the declarative approach, we annotate the methods with the @Transactional annotation.


1 Answers

This should do the job:

<bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
   <property name="entityManagerFactory" ref="myEmf" />
</bean>
<tx:annotation-driven transaction-manager="txManager" />

I have no idea where to look such XML equivalents for other annotations.

http://docs.spring.io/autorepo/docs/spring/4.2.x/spring-framework-reference/html/transaction.html#transaction-declarative-annotations

like image 124
Lakatos Gyula Avatar answered Sep 27 '22 16:09

Lakatos Gyula