Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dali » Eclipse JPA problem on a named query that doesn't have a problem
Eclipse JPA problem on a named query that doesn't have a problem [message #804855] Thu, 23 February 2012 04:24 Go to next message
David Vree is currently offline David VreeFriend
Messages: 48
Registered: July 2010
Member
As of today, I am getting the following JPA error in Eclipse Indigo SR1:

"The identification variable 'name' is not defined in the FROM clause."

on the following class that I haven't touched in weeks and that compiles and runs without issue:

@XmlRootElement(name = "namespace")
@XmlType(name = "namespace",
propOrder = { "name", "description" })
@NamedQueries({ @NamedQuery(name = "NamespaceImpl.findUniqueByName", query = "SELECT n FROM NamespaceImpl n WHERE name = ?1") })
@Entity
@Table(name = "namespc")
public class NamespaceImpl {

private String name;
private String description;

public NamespaceImpl(final String name, final String description) {
this.name = name;
this.description = description;
}

@XmlElement
@Column(nullable = false, unique = true, length = 20)
@Override
public String getName() {
return name;
}

@Override
public void setName(final String name) {
this.name = name;
}

@XmlElement
@Column(length = 80)
@Override
public String getDescription() {
return description;
}

@Override
public void setDescription(final String description) {
this.description = description;
}

public NamespaceImpl() {
super();
}
}

Something must have changed recently, but I don't know what. The project is built with Maven and has the JPA facet. The JPA Platform for the project is set to "Generic 2.0" and the implementation has been set to "disable library configuration".
Re: Eclipse JPA problem on a named query that doesn't have a problem [message #805245 is a reply to message #804855] Thu, 23 February 2012 14:41 Go to previous messageGo to next message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 475
Registered: July 2009
Senior Member
David,

I'm not sure if the query changed or perhaps your Eclipse Dali version changed, but from looking at it, I would think your query should be:

@NamedQueries({ @NamedQuery(name = "NamespaceImpl.findUniqueByName", query = "SELECT n FROM NamespaceImpl n WHERE n.name = ?1") })

Note the reference to "name" is now qualified by the identification variable 'n'. This should resolve the issue.

Neil

Re: Eclipse JPA problem on a named query that doesn't have a problem [message #808791 is a reply to message #805245] Tue, 28 February 2012 06:24 Go to previous message
David Vree is currently offline David VreeFriend
Messages: 48
Registered: July 2010
Member
Indeed it did fix the problem. Thank you very much. As the named query hasn't changed, it must have been a Dali update to Indigo that trigger the validation error. I didn't know where clause variables needed qualification when selecting from just one table.

One other thing to note, when I fixed it and saved the Java file, for whatever reason, it did not trigger a revalidation. I had to explicitly trigger one by hand. Not sure what is up with that....
Previous Topic:Unable to generate JAXB classes
Next Topic:NPE in Indigo SR2 when adding JPA facet
Goto Forum:
  


Current Time: Tue Apr 23 06:10:50 GMT 2024

Powered by FUDForum. Page generated in 0.03388 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top