Grails服务中重复的transactionManager属性 [英] Duplicated transactionManager property in Grails service

查看:67
本文介绍了Grails服务中重复的transactionManager属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当实现专门的Grails服务(从另一个具体的服务类继承)时,我最终得到一个奇怪的重复的transactionManager属性.这是检查专用服务类时得到的:

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:

两个服务类都注释为@Transactional:

Both service classes are annotated as @Transactional:

@Transactional(readOnly = true)
class FormularioService {
}

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

此行为导致在事务AOP期间出现NullPointerException.

This behavior leads to NullPointerException's during transaction AOP.

1)实例如何具有两个具有相同名称的属性?

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

2)我该怎么做才能保留具有单个transactionManager属性的服务(非专业服务类只是不会出现此类错误)

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)

推荐答案

如果超级类已经被注释,则永远不要使用@Transactional对专用服务类进行注释.

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 {
}

更多详细信息,请访问 https://stackoverflow.com/a/37769357/1916198

More details at https://stackoverflow.com/a/37769357/1916198

这篇关于Grails服务中重复的transactionManager属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆