openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter (JIRA)" <>
Subject [jira] Commented: (OPENJPA-312) derby fails with duplicate primary key(s) in group by list
Date Fri, 10 Aug 2007 16:59:42 GMT


Kevin Sutter commented on OPENJPA-312:

The basic idea of the patch looks okay, but the code changes do not look consistent.  In some
cases, you use "sql" and in others, you are using "sql.getSQL()".  I would prefer just using

Also, you check for an empty _grouping after you check if the desired group sub-string is
already present in the _grouping.  This seems backwards.  I know it's only being used to determine
whether to use a comma or not.  So, instead of doing these extra empty checks, could we do
something along the following.  I think this accomplishes the same goal.

         getJoins(joins, true);
         if (_grouping == null) {
             _grouping = new SQLBuffer(_dict);
        else if (_grouping.getSQL().indexOf(sql) < 0) 
             _grouping.append(", " + sql);


> derby fails with duplicate primary key(s) in group by list
> ----------------------------------------------------------
>                 Key: OPENJPA-312
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: sql
>    Affects Versions: 1.0.0
>            Reporter: Daniel Lee
>            Assignee: Daniel Lee
>            Priority: Minor
>             Fix For: 1.0.0
>         Attachments: OPENJPA-312.patch
> derby fails with duplicate primary key(s) in group by list
> With query "select o.customer, avg(o.amount) from Order o group by o.customer" the push-down
query contains duplicate columns in the group by clause.  This is okay when DB2 and other
DB that tolerate the duplicates but Derby returns error.
> Of course, we can ask fix on Derby but we can also easy fix in OpenJPA to avoid duplicates
in the group by list.  Please refer to the following for the error result and the attach patch
for the fix.
> Output from running the query that generate duplicate in the group by list:
> 6429  demo  TRACE  [main] openjpa.Query - Executing query: select o.customer, avg(o.amount)
from Order o group by o.customer
> 6639  demo  TRACE  [main] openjpa.jdbc.SQL - <t 1094861122, conn 1639735740> executing
prepstmnt 1405375428 SELECT t1.countryCode,, t1.version,, t1.state, t1.street,, t1.creditRating,, AVG(t0.amount) FROM Order t0 INNER JOIN Customer t1 ON t0.customer_countryCode
= t1.countryCode AND t0.customer_id = GROUP BY t1.countryCode,, t1.version, t1.countryCode,,, t1.state, t1.street,, t1.countryCode,, t1.creditRating,

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message