[squid:S3749] Should consider @PersistenceContext a valid injection


(KC Baltz) #1
  • SonarQube 7.3
  • squid:S3749 (Members of Spring components should be injected) doesn’t recognize @PersistenceContext (from javax.persistence) as an auto-injection
  • Have a @Repository class with a member variable annotated with @PersistenceContext. Variable gets flagged as a violation of this rule.
  • Workaround: Use the customInjectionAnnotations parameter of this rule to add javax.persistence.PersistenceContext as a valid annotation.

Sample:

@Repository
class MyRepo
{
    @PersistenceContext
    private EntityManager em; // This line gets tagged with the rule