0
votes

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:

enter image description here

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)

1
grails.1312388.n4.nabble.com/… This is really old news/stuff - stick to the one that works. At some point during grails 2 transaction changed from spring to Grails. In Grails 3 you must use the newer method - V H
I'm sticking to grails transactions/annotations (at least I think so), using Grails 2.4.3. I'll try a Grails update to 2.5 and see how things go - but I don't think I can do a major update to Grails 3. - Cléssio Mendes

1 Answers

0
votes

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 https://stackoverflow.com/a/37769357/1916198