Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dali » JPA validation error on JPQL long state field path
JPA validation error on JPQL long state field path [message #819352] Mon, 12 March 2012 20:19 Go to next message
David Vree is currently offline David VreeFriend
Messages: 45
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 #820182 is a reply to message #819352] Tue, 13 March 2012 20:40 Go to previous messageGo to next message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 470
Registered: July 2009
Senior Member
David,

It looks like you've found a bug in Dali. We were not handling the specified target entity correctly in this case. Someone is working on a fix for this and it will be made available in the next service patch and new release (Juno). Unfortunately for now, the only thing you can do is to turn off or turn down JPQL validation, which can be done in the project or workspace preferences. You could set these types of errors to be warnings instead, and this way you could still get some validation but could more easily ignore the incorrect validation.

Thanks for the detailed write-up and sorry for the inconvenience.

Neil
Re: JPA validation error on JPQL long state field path [message #820296 is a reply to message #820182] Wed, 14 March 2012 00:29 Go to previous messageGo to next message
David Vree is currently offline David VreeFriend
Messages: 45
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

Re: JPA validation error on JPQL long state field path [message #820992 is a reply to message #820296] Wed, 14 March 2012 20:38 Go to previous messageGo to next message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 470
Registered: July 2009
Senior Member
Thanks David...we'll look into that as well.

Neil
Re: JPA validation error on JPQL long state field path [message #876577 is a reply to message #819352] Thu, 24 May 2012 21:46 Go to previous messageGo to next message
Kenneth Cheung is currently offline Kenneth CheungFriend
Messages: 9
Registered: July 2009
Junior Member
Is there a bugzilla for this? Thanks.
Re: JPA validation error on JPQL long state field path [message #879012 is a reply to message #876577] Wed, 30 May 2012 11:13 Go to previous message
Karen Butzke is currently offline Karen ButzkeFriend
Messages: 220
Registered: July 2009
Senior Member
bug 374145
bug 378373
Previous Topic:validation error
Next Topic:JPA + Hibernate + Sybase ASE
Goto Forum:
  


Current Time: Sat Dec 20 01:40:33 GMT 2014

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

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