surinder-insonix / datanucleus-appengine

Automatically exported from code.google.com/p/datanucleus-appengine
0 stars 0 forks source link

Encountered a variable expression that isn't part of a join when accessing variable with alias #184

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Given the following domain object:

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable =
"true")
@Queries({
    @Query(name = "findByUsername", value = "SELECT FROM User u where
u.username == :username")
})
public class User implements DomainObject {
    private static final long serialVersionUID = 1L;

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;

    @Persistent
    private String username;

    // ... other fields and getters/setters
}

Executing the named query "findByUsername" works in version
datanucleus-appengine 1.0.3 but throws JdoUsageException ("Encountered a
variable expression that isn't part of a join") when executed in version
1.0.4.1.

This is valid usage according to jdo spec.

Original issue reported on code.google.com by portfami...@gmail.com on 8 Jan 2010 at 12:06

GoogleCodeExporter commented 8 years ago
Workaround to this example is remove alias so the query is just "SELECT FROM 
User
where username == :username", but this might not be able to be done for more 
complex
queries.

Original comment by portfami...@gmail.com on 8 Jan 2010 at 12:08

GoogleCodeExporter commented 8 years ago
The "workaround" is not a workaround; your input query is basically wrong and 
not
correct JDOQL. You cannot define an alias on the candidate. The alias is "this" 
as
per Java, which is the whole point of JDOQL. Please familiarise yourself via 
the JDO spec

Original comment by googleco...@yahoo.co.uk on 8 Jan 2010 at 4:23

GoogleCodeExporter commented 8 years ago
Thanks Andy, I didn't realise you could only use aliases in subqueries. What 
threw me
was this was working on version 1.0.3 and only started failing after an upgrade 
to
1.0.4.1.

Please close this defect.

Original comment by portfami...@gmail.com on 9 Jan 2010 at 1:12

GoogleCodeExporter commented 8 years ago

Original comment by max.r...@gmail.com on 9 Jan 2010 at 1:14