Skip to main content


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: 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 #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: 475
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: 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

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: 475
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 messageGo to next message
Karen Butzke is currently offline Karen ButzkeFriend
Messages: 220
Registered: July 2009
Senior Member
bug 374145
bug 378373
Re: JPA validation error on JPQL long state field path [message #1734397 is a reply to message #879012] Tue, 07 June 2016 21:46 Go to previous message
David Vree is currently offline David VreeFriend
Messages: 48
Registered: July 2010
Member
Karen Butzke wrote on Wed, 30 May 2012 07:13
bug 374145
bug 378373


Hi, just following up on issue 374145. I am running Eclipse Luna with Dali JPA Core 3.4.0v2013120521 and I am still seeing this issue (the original one about the state field path -- the other one #378373 about changing the problem to information has been fixed).

My project is JPA faceted version 2.1. Was there a regression along the way? It's the same error message on the same line(s) of code....
Previous Topic:Preselected JPA Platform and Implementation on JPA Facet page?
Next Topic:Configure Default on New JPA Project Wizard
Goto Forum:
  


Current Time: Tue Mar 19 04:59:20 GMT 2024

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

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

Back to the top