From Bugzilla Helper:
User-Agent: Mozilla/5.0 Galeon/1.2.7 (X11; Linux i686; U;) Gecko/20030131
Description of problem:
When using DataQuery.addPath() to add paths to a retrieve all, the query would
IllegalStateException: container is null but value isn't
if the path contained more than one object type reference (e.g.
However, if you did:
they query would succeed.
After talking with Rafi it appears that the "id" attributes for intermediate
object types are not being automatically added, as the javadoc says they will.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. add a path with more than one object type to a DataQuery
Actual Results: IllegalStateException on query.next()
Expected Results: no IllegalStateException
There is a easy workaround: simply add the path to the "id" attributes manually.
However, because this is in direct contradiction of the javadoc, and because
the workaround is not intuitive from the error message, I'm leaving it marked as
Here's the full text of the conversation between Rafi and I:
(16:09:46) Me: ping
(16:09:52) Rafi Schloming: pong
(16:11:08) Me: Hey, I'm trying to use DataQuery.addPath to filter on attributes
of associated objects, and I'm getting an IllegalStateException at RecordSet:151
(16:11:18) Me: "container is null but value isn't
(16:11:21) Me: "
(16:11:31) Me: Any idea why that would be?
(16:12:58) Rafi Schloming: Are you doing this with a freaky data query?
(16:13:18) Me: No, a SessionManager.getSession().retrieve(String)
(16:13:38) Rafi Schloming: What that means is that the record set is trying to
translate a flat row returned by the query into an object graph.
(16:14:04) Rafi Schloming: And it encoutered an inconsistent set of values.
(16:14:30) Rafi Schloming: Namely somePath.id is null, but somePath.attribute is
(16:15:13) Rafi Schloming: Which isn't consistent since somePath.attribute needs
to be contained in *some* object.
(16:15:22) Me: Does the addPath() let you reference attribute in collection
(16:15:52) Rafi Schloming: But if somePath.id is null then there is no way to
tell where in the session to put the attribute value.
(16:16:02) Rafi Schloming: Yes, I believe it does.
(16:16:34) Me: If I only want the id, can I reference "somePath.id" ?
(16:16:39) Rafi Schloming: It will change the multiplicity of your query though
unless you add a filter that constrains stuff appropriately.
(16:16:45) Rafi Schloming: Yeah you can.
(16:17:11) Me: Hmmm, okay, let me take a look at the code again.
(16:17:35) Rafi Schloming: I'd say the possible causes are:
(16:17:58) Rafi Schloming: 1. addPath() isn't doing quite the right thing since
it should be automatically adding id properties if they aren't specified.
(16:18:40) Rafi Schloming: 2. SQL generation is producing a wacked out query
that is returning null values for ids and non null values for attributes.
(16:19:25) Rafi Schloming: If you turn logging for com.redhat.persistence up to
INFO we should be able to figure out whats going on pretty easily.
(16:19:51) Rafi Schloming: It will print the query it is actually executing
along with the values it's resurrecting and soforth.
(16:21:12) Me: okay
(17:15:32) Me: So I was doing something like
'query.addPath("assoc1.assoc2.assoc3.id")' and it was failing.
etc. caused it to work.
(17:16:53) Rafi Schloming: Ah yes, so I just need to make it auto-add id
properties all the way up the path being added.
(17:17:04) Rafi Schloming: I probably forgot the recursive check or something
(17:17:08) Me: Yes, that sounds like the issue
(17:17:22) Rafi Schloming: Wanna file a bz?
(17:17:27) Me: sure
(17:17:38) Rafi Schloming: thanks
fixed on 6.0 branch (35593) and tip (35575, 35590)