1

I scanned my Maven repository with JQassistant. Now I would like to find out which classes are annotated by @Stateful. But even using

MATCH (a:Java:Value:Annotation) RETURN DISTINCT a.name

returns no rows as result. Are annotations not a part of repository scanning? Or do I write a wrong query?

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142

1 Answers1

2

the following query will return all classes annotated by @Stateful

MATCH
  (t:Type)-[:ANNOTATED_BY]->()-[:OF_TYPE]->(statefulType:Type)
WHERE
  statefulType.fqn = "javax.ejb.Stateful"
RETURN
  t.fqn

If you've scanned a repository it might be useful to also return the artifact that contains these types:

MATCH
  (a:Artifact)-[:CONTAINS]->(t:Type),
  (t)-[:ANNOTATED_BY]->()-[:OF_TYPE]->(statefulType:Type)
WHERE
  statefulType.fqn = "javax.ejb.Stateful"
RETURN
  a.fqn, collect(t.fqn)
Dirk Mahler
  • 1,186
  • 1
  • 6
  • 7
  • That works, thank you. Do you know why my query does not return any rows? – J Fabian Meier Apr 29 '16 at 13:33
  • Ok, probably because the Java:Value:Annotation has no content. – J Fabian Meier Apr 29 '16 at 14:08
  • Just verified your first query - the cause is that the scanner did not add the Java label to the annotation node but the documentation proposes that it's there. I've created an issue (https://github.com/buschmais/jqassistant/issues/378), will be fixed with the next release. – Dirk Mahler Apr 30 '16 at 17:55