question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

warning on JPA annotations applied to fields

See original GitHub issue

What I thought we had decided was that when you have a Java annotation of a Ceylon attribute, then the annotation always gets applied to the field, eliminating any ambiguity that it might be applied to the getter.

And in fact, this is what seems to actually happen. (Phew! I was really worried for a sec.) But I still get a warning from the Java backend:

Ambiguous annotation target: generatedValue could be applied to several targets, use one of generatedValue__FIELD, generatedValue__GETTER to disambiguate

That warning should be removed, I believe.

WDYT, @tombentley ?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:35 (35 by maintainers)

github_iconTop GitHub Comments

2reactions
gavinkingcommented, Oct 13, 2016

I just tried @DiegoCoronel’s example Swarm app, and I found that when I used inject instead of inject__FIELD, I still get these useless warnings.

source/jaxrs/example/provider/PersistenceProvider.ceylon:15: warning: ambiguous annotation target: persistenceContext could be applied to several targets, use one of persistenceContext__FIELD, persistenceContext__GETTER, persistenceContext__SETTER to disambiguate
        persistenceContext
        ^
source/jaxrs/example/resource/EmployeeResource.ceylon:37: warning: ambiguous annotation target: inject could be applied to several targets, use one of inject__FIELD, inject__GETTER, inject__SETTER to disambiguate
        inject
        ^
source/jaxrs/example/resource/EmployeeResource.ceylon:40: warning: ambiguous annotation target: inject could be applied to several targets, use one of inject__FIELD, inject__GETTER, inject__SETTER to disambiguate
        inject
        ^
4 warnings

I seriously do not know what the purpose of this is supposed to be. If I have:

shared class EmployeeResource() {

    inject
    late EntityManager entityManager;

    inject
    late EmployeeService service;

        ...

}

Seriously what do I care if the @Inject annotation gets applied to the field or to the getter? It’s not even confusing to Java folks, since the declaration actually looks like a Java field!

0reactions
FroMagecommented, Oct 20, 2016

So nobody’s going to pick up on what I said about not needing late for primitives and optionals?

Read more comments on GitHub >

github_iconTop Results From Across the Web

I want to generate a compile warning for JPA annotations with ...
I've tried using the fully qualified names in the pointcut @javax.persistence.Enumerated(javax.persistence.EnumType.ORDINAL) but still got the ...
Read more >
JPA Annotations - Hibernate Annotations - DigitalOcean
JPA annotations are used in mapping java objects to the database tables, columns etc. Hibernate is the most popular implement of JPA ......
Read more >
Chapter 2. Mapping Entities - Red Hat on GitHub
JPA entities are plain POJOs. Actually, they are Hibernate persistent entities. Their mappings are defined through JDK 5.0 annotations instead of hbm.xml files....
Read more >
The @SuppressWarnings Annotation in Java - GeeksforGeeks
The @SuppressWarnings Annotation in Java ; All, It will suppress all warnings. ; Cast, Suppress the warning while casting from a generic type...
Read more >
Lombok and JPA: What may go wrong? - JPA Buddy
Entity classes often get annotated with @EqualsAndHashCode or @Data . The documentation of @EqualsAndHashCode states: By default, it'll use all ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found