Hello all--
I am curious to know how (if possible) to reference a PK field using EJBQL.
I tried using the normal expression "db:" syntax but as I saw in the source
this won't work. EJBQLPathTranslator.processLastPathComponent() appears to
assume that the last part of any path will reference either an ObjAttribute
or an ObjRelationship, and will throw an IllegalStateException if neither of
these are the case.
I'd like to have access to the PK field for a couple of purposes. One, when
doing COUNT queries it is faster to do a COUNT(PK) than a COUNT(*).
Furthermore, I want to be able to essentially group aggregate function
results by objects, which would be impractical to do using the OBJECT(e)
notation, so the plan was to perform the group query using IDs and then fill
in the results with objects on the way out.
Since the call from processLastPathComponent() to
processTerminatingAttribute() just resolves into a DbAttribute and thus a
column name anyway, wouldn't it be rather simple patch to do a "db:" check
on the path component and presume a DB column name instead of an
ObjAttribute name? I imagine I may be oversimplifying the situation, but if
not and there is agreement on the method I don't mind doing the patch.
Of course, if there is an alternative way to reference PKs that I'm unaware
of please enlighten me :-).
Thanks--
Dave
This archive was generated by hypermail 2.0.0 : Thu Dec 03 2009 - 17:06:21 EST