Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transactional annotation on interface method doesn't work with cglib [SPR-975] #5688

Closed
spring-projects-issues opened this issue May 22, 2005 · 1 comment

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented May 22, 2005

Charles Blaxland opened SPR-975 and commented

It appears that if you add an @Transaction annotation to the declaration of a method in an interface and use CGLIB proxies, then the transactional advice is not honoured. This works, however, if you use JDK proxies instead of CGLIB, or if you put the annotation on the actual implementation of the method.

Also see http://forum.springframework.org/viewtopic.php?p=21043#21059


Affects: 1.2 final

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jun 4, 2005

Juergen Hoeller commented

This is actually caused by the way that JDK 1.5 annotations handle inheritance: Class-level annotations may be inherited from superclasses, but that's about it. No inheritance from implemented interfaces, and no inheritance at the method level.

Have a look at JDK 1.5's Inherited meta-annotation, which defines that contract. Spring's Transactional annotation is marked as Inherited; there doesn't seem to me more we can do. The limitation is caused by JDK 1.5's general annotation model, not by Spring's use of it.

The consequence is that annotations should always be present on the actually invoked method or class. In case of a JDK proxy, that would be the interface; in case of a CGLIB proxy, that would be the concrete target class.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants