logo
down
shadow

Making specific method non transactional in Spring


Making specific method non transactional in Spring

By : Michiel van Wessem
Date : November 24 2020, 05:44 AM
Hope that helps Spring Batch is inherently transactional. Even if your datasources are not transactional, the semantics of the JobRepository require it. The closest you can get with Spring Batch and not being transactional is using the ResourcelessTransactionManager. This transaction manager is essentially a no-op transaction manager that just keeps track of if an operation is within the scope of a transaction or not.
code :


Share : facebook icon twitter icon
Understanding Spring transactions - What happens when a transactional method calls another transactional method?

Understanding Spring transactions - What happens when a transactional method calls another transactional method?


By : user2452748
Date : March 29 2020, 07:55 AM
wish helps you Two answers:
a) don't do it. Use @Transactional in the service layer or the dao layer, but not both (the service layer is the usual choice, as you probably want one transaction per service method)
code :
proxy      bean  
a() -->    a()
            |
            V  
b() -->    b()
           proxy      bean
service    a() -->    a()
                       |
             /---------/
             |                 
             V
dao        b() -->    b()
Making Spring 3 MVC controller method Transactional

Making Spring 3 MVC controller method Transactional


By : Long Doan
Date : March 29 2020, 07:55 AM
Any of those help You'll need to implement an interface so that Spring has something it can use as a Proxy interface:
code :
@Controller
public interface AuthenticationController {
  ModelAndView home(HttpServletRequest request, HttpServletResponse response);
}

@Controller
public class AuthenticationControllerImpl implements AuthenticationController {

@RequestMapping(value="/home.html",method=RequestMethod.GET)
@Transactional
@Override
ModelAndView home(HttpServletRequest request, HttpServletResponse response){
.....
}
}
Transactional method in Scala Play with Slick (similar to Spring @Transactional, maybe?)

Transactional method in Scala Play with Slick (similar to Spring @Transactional, maybe?)


By : Paul Graham
Date : March 29 2020, 07:55 AM
help you fix your problem There is no such thing as transactional annotations or the like in slick. Your second "do not want" is actually the way to go. It's totally reasonable to return DBIO[User] from your DAO which does not defeat their purpose at all. It's the way slick works.
code :
class UserController @Inject(userService: UserService) {
  def register(userData: UserData) = {
    userService.save(userData).map(result => Ok(result))
  }
}

class UserService @Inject(userDao: UserDao, addressDao: AddressDao) {
  def save(userData: UserData): Future[User] = {
    val action = (for {
      savedUser <- userDao.save(userData.toUser)
      savedAddress <- addressDao.save(userData.addressData.toAddress)
      whatever <- DBIO.successful(nonDbStuff)
    } yield (savedUser, savedAddress)).transactionally

    db.run(action).map(result => result._1.copy(result._2))
  }
}

class SlickUserDao {
  def save(user: User): DBIO[User] = {
    (UserSchema.users returning UserSchema.users).insertOrUpdate(user)
  }
}
Spring transactional method gets rollback even if exception is catched in non-transactional method or in controller

Spring transactional method gets rollback even if exception is catched in non-transactional method or in controller


By : Octavio
Date : March 29 2020, 07:55 AM
Any of those help
Does this mean that the proxy that spring uses already rolled back the transaction even before i catch the exception?
Spring Boot With @Transactional annotated method, calls other transactional methods and throws an Exception

Spring Boot With @Transactional annotated method, calls other transactional methods and throws an Exception


By : user3524703
Date : March 29 2020, 07:55 AM
I hope this helps . Make sure that the method annotated with @Transactional is declared as public and called by a different class.
A transactional method must be public so that Spring can override it and it must be called from outside the defining class so that the invocation can go through a proxy.
Related Posts Related Posts :
  • Autowired not happening for bean with @Async method
  • Spring Framework does not required sever. Is it true?
  • How to implement Generics DAO with Spring JDBC template
  • Escaping a | (pipe) in SpEL
  • Spring: Using @Qualifier with Property Placeholder
  • abount the singleton beans of spring
  • Spring @Autowired Not Working Error Creating Bean Injection Of Autowire dependencies failed
  • Spring-MVC Exception handler returns OK when writing into response
  • My applicationContext.xml is not valid when i deploy my project on tomcat7:org.springframework.beans.factory.parsing.Bea
  • Storing trailing zeroes in database with JPA and Oracle
  • Spring more than one profile and ${spring.profiles.active}
  • Spring Batch - interrupt thread when job stops
  • Can I use spring AOP to log start and end of a method to help easy debuging
  • How to use different error codes for validation messages?
  • Spring Data Rest and collections with unique constraints
  • Thymeleaf + Spring Checkboxes not binding
  • Spring Boot: Publish Thymeleaf template without restarting the server
  • How long will Spring 3.x continue to be supported?
  • Spring Security without a login form
  • SOAP UI not finding WSDL depending XSD files in Spring WS Soap Service
  • Spring MVC- Joda datetime error message for invalid date
  • Broadleaf Demosite on JBOSS 7
  • Spring Mongo mapping variable data
  • MySQL and Infinispan - JTA implementation
  • spring boot autoconfiguration with jdbc template autowiring dataSource issue
  • Hibernate and @SessionAttribute
  • DefaultMessageListenerContainer threading issue
  • Good sample spring and hibernate web application book?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org