52297

Duplicated transactionManager property in Grails service

Question:

When implementing a specialized Grails service (inherited from another concrete service class) I'm ending up with a weird duplicated transactionManager property. Here is what I get when inspecting the specialized service class:

<a href="https://i.stack.imgur.com/OYlQf.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/OYlQf.png" data-original="https://i.stack.imgur.com/OYlQf.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

Both service classes are annotated as @Transactional:

@Transactional(readOnly = true) class FormularioService { } @Transactional(readOnly = true) class FormularioCurriculoService extends FormularioService { }

This behavior leads to NullPointerException's during transaction AOP.

1) How can an instance has two properties with the same name?

2) What could I do to keep services with a single transactionManager property (non-specialized service classes just don't present this kind of bug)

Answer1:

Just NEVER annotate an specialized service class with @Transactional, if the super class is already annotated.

@Transactional(readOnly = true) class FormularioService { } //Don't annotate with @Transactional class FormularioCurriculoService extends FormularioService { }

More details at <a href="https://stackoverflow.com/a/37769357/1916198" rel="nofollow">https://stackoverflow.com/a/37769357/1916198</a>

Recommend

  • How to send data to the server with an image?
  • Consolidate SQL Server databases into 1
  • BCP from One Table to Another table in different servers in SQL Server 2008 R2
  • How can I get the default value of a field in a class in C#?
  • Angular component host element width and height are 0
  • Debugging OpenLaszlo SWF runtime applications and the Laszlo Foundation Classes (LFC) with Flash Bui
  • Posting comment with ajax and jquery
  • Configure a Spring bean callback on server startup?
  • Elixir Phoenix inlining css for sending emails
  • understanding withNewSession in Grails
  • Spring transactions & hibernate: lazy initialization
  • Spring instantiates bean but can't use it
  • stored procedures and banks
  • How to run update query in Spring JPA for quartz job
  • Lightweight Generics and class methods
  • Glassfish denies access to JSF page, returning 403 HTTP response code
  • How to Detect if an XML Element is Empty using DOMDocument in PHP?
  • How to call Service in Grails with groovy
  • One transaction for several JpaRepositories' methods
  • Fonts changing weight when uploaded to web server
  • Spring @ExceptionHandler does not return content unless body is empty
  • open source, multi-platform, browser-based screen capture extension? [closed]
  • How to access the element at variable index of a tuple?
  • Is it good to have multiple database running in a same project?
  • Exclude resource paths from Jersey application.wadl?
  • EventLog logs in Application, even though set to another log
  • Grails Cannot get property 'id' on null object
  • add new field to form with rvest
  • Does CSS support inheritance [duplicate]
  • C#: Import/Export Settings into/from a File
  • Why use database factory in asp.net mvc?
  • Can someone please explain to me in the most layman terms how to use EventArgs?
  • ViewController With Transparent Background Entering Current ViewController With Push Transition
  • how to save the state in userdefaults of accessory checkmark-iphone
  • Database structure design with variable amounts of fields
  • How do I fake an specific browser client when using Java's Net library?
  • How to get a value (ex: baseURL) in every Karate feature?
  • Statically linking a C++ library to a C# process using CLI or any other way
  • python regex in pyparsing
  • Checking variable from a different class in C#