cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Lamy <davel...@gmail.com>
Subject Bug with EJBQL query referencing two subclasses?
Date Tue, 14 Sep 2010 14:54:37 GMT
Hello Cayenne gurus--

I hit a SQL syntax problem yesterday while trying to issue a EJBQL query to
determine value uniqueness within a given parent "context".  The EJBQL query
is:

SELECT COUNT(distinct a.id) FROM Clip AS a JOIN a.timeline b WHERE a.name =
?1 AND b = ?2    [{foo,200}]

The interesting part about this structure is the both Clip and Timeline (the
target class of the .timeline association) both descend from a common
abstract parent class.  The query is attempting to determine whether the
name "foo" is unique within the context of the clip's timeline, which has a
PK of 200.

Here is the resulting SQL:

SELECT COUNT(DISTINCT t0.ID) AS sc0 FROM TIMELINE_SEGMENT t0 INNER JOIN
TIMELINE_SEGMENT t1 ON (t0.TIMELINE_ID = t1.ID) WHERE *t0.SEGMENT_TYPE = ?
t1.SEGMENT_TYPE = ?* AND t0.NAME = ? AND t1.ID = ? [bind: 1:'CLIP',
2:'TIMELINE', 3:'foo', 4:200]

As you can see, the SQL generation skips an "AND" in between the two
qualifier clauses.  The rest of the SQL looks perfect, but this missing AND
is obviously messing things up.

I upgraded to 3.1 and the problem still occurs.  I can submit a JIRA on this
but would like the opportunity to investigate and fix it.. I need this code
to work now and so can run with a patched version until a fix is formally
introduced.  So, I was hoping that someone could give me a starting point to
look.  What classes would probably be involved in this clause creation?

Thanks for any help with resolving this one--

Dave

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message