JPA validation error on JPQL long state field path [message #819352] |
Mon, 12 March 2012 20:19 |
David Vree Messages: 48 Registered: July 2010 |
Member |
|
|
I am getting the following JPA validation error on a JPQL named query -- that successfully compiles and runs with Hibernate as the JPA provider. I am just trying to understand if the problem is in my code (and I got lucky) or if the problem is in the JPA validation feature around state fields, or both.
The error is this:
"The state field path 'cl.namespace.id' cannot be resolved to a valid type."
It stems from the following named query on the class "cal".
@Entity
@Access(AccessType.PROPERTY)
@Table(name = "cal")
@NamedQueries({ @NamedQuery(name = "CalImpl.findByNamespace", query = "SELECT cl FROM CalImpl cl WHERE cl.namespace.id = ?1") })
public class CalImpl {
.....
private Namespc namespace;
@Override
@ManyToOne(optional = false, targetEntity = NamespaceImpl.class, fetch = LAZY)
@JoinColumn(name = "namespace_id", nullable = false)
public Namespc getNamespace() {
return namespace;
}
public void setNamespace(final Namespc namespace) {
this.namespace = namespace;
}
Without providing the full class definitions, you can see that each CalImpl has a private field "namespace" (with getter and setter). Note that CalImpl declares the "namespace" field as an interface "Namespc". The "Namespc" interface has a "getId" property getter and the implementation class "NamespaceImpl" has a private field "id" and implements the Namespc interface.
Currently I am thinking that there is an issue with JPA validation because according to the JPA 2 spec, it should be possible to have path expressions that concatenate multiple state fields. From the spec page 127:
"Path expressions can be composed from other path
expressions if the original path expression evaluates to a single-valued type (not a collection).
In the following example, contactInfo denotes an embeddable class consisting of an address and
set of phones. Phone is an entity.
SELECT p.vendor
FROM Employee e JOIN e.contactInfo.phones p
WHERE e.contactInfo.address.zipcode = '95054'
Path expression navigability is composed using "inner join" semantics."
Also I noticed that the code completion for state fields only works for local fields and does not seem to cross over into other persistence types.
[Updated on: Tue, 13 March 2012 03:50] Report message to a moderator
|
|
|
|
Re: JPA validation error on JPQL long state field path [message #820296 is a reply to message #820182] |
Wed, 14 March 2012 00:29 |
David Vree Messages: 48 Registered: July 2010 |
Member |
|
|
Thank you for your reply. I did turn down the JPA validation for this issue from Error to Warning and interestingly, it disappeared altogether -- which is indicative of another problem I think.
I tried setting it to warning on two different machines and got the same result.
Here is the content of my prefs file:
eclipse.preferences.version=1
org.eclipse.jpt.core.platform=generic2_0
org.eclipse.jpt.jpa.core.discoverAnnotatedClasses=false
problem.JPQL_QUERY_VALIDATION=warning
problem.PROJECT_NO_CONNECTION=ignore
workspace_preferences_overriden=true
I look forward to the update, if you need a beta tester let me know.
[Updated on: Wed, 14 March 2012 00:30] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05061 seconds