Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPA Warning: "No mapping is associated with the state field path 't.progress'"

I'm using JPA (EclipseLink 2.4.1) with a mapping-file containing named-queries. Eclipse shows me the following warning message in my mapping file:

No mapping is associated with the state field path 't.progress'.

The warning is of the type JPA Problem. The corresponding lines in my named-queries.xml-file look like this:

<named-query name="FinishedTasks">
    <query><![CDATA[SELECT t FROM Task t WHERE t.progress = 100]]></query>
</named-query>

However, the query runs fine when executed, so no warning in run-time.

Here's what the file Task.java looks like (excerpt):

@Entity
public class Task extends Issue {
    private Integer progress = 0;
    public Integer getProgress() {
        return progress;
    }

    public void setProgress(final Integer progress) {
        this.progress = progress;
    }
}

Issue.java looks like this (excerpt):

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Issue implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;

    public long getId() {
        return id;
    }
    public void setId(final long id) {
        this.id = id;
    }
}

I have no warnings about queries using Issue.

So my question is, how do I get rid of the warning? And does the warning have some implication I'm not aware of (as said, the query runs fine).

like image 897
Bob Avatar asked Mar 05 '13 14:03

Bob


1 Answers

No mapping is associated with the state field path 't.progress'

I believe this is totally due to the Eclipse JPA Details View (orm.xml editor) and has nothing to do with EclipseLink nor JPA in general. The warning is reminding you that the Named Query is using a JPA query path (t.progress) that is not mapped in the mapping file. The View / xml editor is not analysing the metadata of your java classes, so is not aware whether the it is mapped via JPA annotations.

i.e. the tool is doing the best job for you it possibly can give it's technology / scope limitations.

Solution:

  • understand what the message is saying, manually ensure that the warning is addressed via JPA annotations (OR if you really must, insert the approprate Entity Mappings into your entity mapping XML file), and move on...

:^)

like image 124
Glen Best Avatar answered Oct 12 '22 12:10

Glen Best