-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Using EntityGraph Breaks Collection Query Parameters
PostPosted: Mon Aug 04, 2014 6:22 pm 
Newbie

Joined: Thu Jul 31, 2014 8:55 pm
Posts: 2
I'm playing around with the JPA 2.1 Entity Graphs, and I've run into the following bug in Hibernate 4.3.6.Final:

Code:
Collection<Integer> propertyValues = createValues(); //Generates a list of 5 ids
Query q = manager.createQuery("from MyEntity where child.property IN (:values));
q.setParameter("values", propertyValues);

EntityGraph<MyEntity> graph = manager.createEntityGraph(MyEntity.class);
graph.addAttributeNodes("id");
Subgraph subgraph = graph.addSubgraph("child");
subgraph.addAttributeNodes("property");
subgraph.addAttributeNodes("id");

q.setHint(QueryHints.FETCHGRAPH, graph);
List<MyEntity> result = q.getResultList();


I get the following exception:

Code:
java.lang.NullPointerException: null
   at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:67)
   at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:613)
   at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1900)
   at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1861)
   at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1838)


I did some debugging and found that the following SQL is printed just before the exception:

Code:
select
        myentity0_.my_entity_id as my_enti1_16_,
        myentity0_.date_created as date_cre2_16_,
        myentity0_.child_id as child_id7_16_,
    from
        testschema.My_Entity myentity0_ cross
    join
        testschema.Child child1_
    where
        myentity0_.child_id=child1_.child_id
        and (
            child1_.child_id in (
                ?
            )
        )


If I comment out adding the entity graph, I get no exception as expected, and see the following SQL generated:

Code:
select
        myentity0_.my_entity_id as my_enti1_16_,
        myentity0_.date_created as date_cre2_16_,
        myentity0_.child_id as child_id7_16_,
    from
        testschema.My_Entity myentity0_ cross
    join
        testschema.Child child1_
    where
        myentity0_.child_id=child1_.child_id
        and (
            child1_.child_id in (
                ?, ?, ?, ?, ?
            )
        )


Note the number of "?" in the "in" clause. It appears something about adding an EntityGraph as a query hint causes Hibernate to incorrectly generate the "in" clause, and something internal throws a null pointer.

Help? Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Using EntityGraph Breaks Collection Query Parameters
PostPosted: Sun Dec 07, 2014 9:54 am 
Newbie

Joined: Sun Dec 07, 2014 9:52 am
Posts: 1
I'm facing the same problem. Positional parameters don't work either.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.