openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominik Jall (JIRA)" <>
Subject [jira] [Created] (OPENJPA-2501) MapJoin key() throws NullPointerException
Date Sat, 10 May 2014 22:16:20 GMT
Dominik Jall created OPENJPA-2501:

             Summary: MapJoin key() throws NullPointerException
                 Key: OPENJPA-2501
             Project: OpenJPA
          Issue Type: Bug
          Components: criteria, kernel
    Affects Versions: 2.2.3
         Environment: openjpa-2.2.3-SNAPSHOT-r422266
used in IBM Websphere Liberty profile build
Eclipse Kepler Java EE Release 1 build 20130919-0819
            Reporter: Dominik Jall

I am trying to do a search on a localized string. The strings are mapped by an ElementCollection
of type Map. Key is a string interpreted as locale.

Here is the entity:

@Table(name="category", schema="myschema")
public class Category {

    @GeneratedValue(strategy = GenerationType.AUTO)
    Long id;

    Map<String, String> test = new HashMap<String, String>();


Here is the query:
String search = "%test%";
Locale locale = Locale.ENGLISH;
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<Category> criteria = cb.createQuery(Category.class);
Root<Category> category = criteria.from(Category.class);;
MapJoin<Category, String, String> tests = category.join(Category_.test);

Predicate searchClause = cb.and(
                                cb.equal(tests.key(), locale.toString()), 
                      , search)


When the query is executed, I get this stack trace:

[err] java.lang.NullPointerException
[err]   at org.apache.openjpa.jdbc.kernel.exps.PCPath.<init>(
[err]   at org.apache.openjpa.jdbc.kernel.exps.JDBCExpressionFactory.newPath(
[err]   at org.apache.openjpa.persistence.criteria.Joins$MapKey.toValue(
[err]   at org.apache.openjpa.persistence.criteria.Expressions.toValue(
[err]   at org.apache.openjpa.persistence.criteria.Expressions$Equal.toKernelExpression(
[err]   at org.apache.openjpa.persistence.criteria.PredicateImpl.toKernelExpression(
[err]   at org.apache.openjpa.persistence.criteria.CriteriaExpressionBuilder.evalFilter(
[err]   at org.apache.openjpa.persistence.criteria.CriteriaExpressionBuilder.getQueryExpressions(
[err]   at org.apache.openjpa.persistence.criteria.CriteriaQueryImpl.getQueryExpressions(
[err]   at org.apache.openjpa.persistence.criteria.CriteriaBuilderImpl.eval(
[err]   at org.apache.openjpa.kernel.ExpressionStoreQuery$DataStoreExecutor.<init>(
[err]   at org.apache.openjpa.kernel.ExpressionStoreQuery.newDataStoreExecutor(
[err]   at org.apache.openjpa.kernel.QueryImpl.createExecutor(

I assume the key() function returns an invalid or non-existing path.
When I remove the key() part the query works.

This message was sent by Atlassian JIRA

View raw message