Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] JPA2 ElementCollection quering

We replaced our JPQL parser in 2.4 and kept the previous one available for situations just like the one you are experiencing. We do our best to address issues in the new parser quickly. Please file a bug including the JPQL and object model that cause the problem and the full stack trace. Please also indicate in the bug that it is an issue with the Hermes parser.

-Tom

On 30/01/2013 8:05 AM, Jiri Pejsa wrote:
settings property as you write throw exception class not found:
eclipselink.jpql.parser.

I found information about eclipselink.jpql.parser parameter at
http://eclipse.org/eclipselink/documentation/2.4/jpa/extensions/p_jpql_parser.htm

When I try set property to: org.eclipse.persistence.internal.jpa.jpql.HermesParser

problem still exists and the behaviour is the same. But with property set to
org.eclipse.persistence.queries.ANTLRQueryBuilder, the query works fine. But
this parser is marked as deprecated.

So, set eclipselink.jpql.parser property to
org.eclipse.persistence.queries.ANTLRQueryBuilder solve my problem for now. But
it will be uncomfortable, after ANTLRQueryBuilder will be removed.

Thanx for your help. You saved me a lot of time to solve the problem.



Jiří

Dne 30.1.2013 13:52, Tom Ware napsal(a):
Is the behavior any different when you specify the persistence unit
property:

eclipselink.jpql.parser=eclipselink.jpql.parser

On 30/01/2013 7:35 AM, Jiri Pejsa wrote:
Hello,

I am momentarily working on the project, where we are using
Eclipselink as JPA
provider. The project is JaveEE application runing on Glassfish
3.1.2.2, Java7
and Eclipselink 2.4.0.

I have entity with collections of tags and I need read the entity by
list of its
tags. Pure SQL query is something like this:

SELECT e.* FROM entity e JOIN tags t ON t.entity_id = e.id
WHERE t.tag in ('foo','bar').

My Entity looks like this:
@Entity
publi class Shortcode {
....
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name = "shortcode_groups")
@Column(name = "sc_group")
private List<String> groups;
....
}

next I have Stateless EJB where I define method to reading this
shortcodes:

@Override
@SuppressWarnings("unchecked")
public List<Shortcode> findAllByGroups(List<String> groups) {
if (groups != null && !groups.isEmpty())
     return em.createQuery("SELECT s FROM Shortcode s WHERE s.groups IN
:groups", Shortcode.class).setParameter("groups",
groups).getResultList();
else
     return Collections.emptyList();
}

and this method i called by:
List<Shortcode> shortcodes =
shortcodeService.findAllByGroups(Arrays.asList("cz", "903"));

This should work
(http://stackoverflow.com/questions/2772305/jpql-in-clause-java-arrays-or-lists-sets)


and select all Shortcodes with "tags" 'cz' and '903'. But calling method
shortcodeService.findAllByGroups(Arrays.asList("cz", "903")) throw an
exception:


Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services -
2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Problem compiling [SELECT s FROM Shortcode s WHERE
s.groups IN :groups].
[32, 40] The state field path 's.groups' cannot be resolved to a
collection type.

And I dont know what is wrong on this approach. How can I find
Shortcodes by
collections on "group" ?

I look forward to hearing from you.

Jiri
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top