2013-09-10

Jira: "Passed List had more than one value."

This error happens in Atlassian Jira, as they maliciously and intentionally avoid using foreign keys and unique indices in their table design.
If you see the following error in your tomcat log, you have to do a cleanup:
2013-01-01 01:01:01,111 ajp-8009-1 ERROR      [500ErrorPage.jsp] Exception caught in 500 page org.apache.jasper.JasperException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Passed List had more than one value. 
org.apache.jasper.JasperException: org.apache.jasper.JasperException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Passed List had more than one value. 
(...)
Caused by: java.lang.IllegalArgumentException: Passed List had more than one value. 
        at org.ofbiz.core.entity.EntityUtil.getOnly(EntityUtil.java:62) 
(...)
This actually deletes all the duplicated rows, to make every row to be unique (over 'username', at least):
DELETE FROM columnlayout
WHERE ROWID IN (
      SELECT "ROWID" FROM (
            SELECT RANK() OVER(PARTITION BY USERNAME ORDER BY ROWID) RANK_N, ROWID AS "ROWID" FROM columnlayout
            WHERE USERNAME IN (
                  SELECT USERNAME FROM columnlayout
                  GROUP BY USERNAME
                  HAVING COUNT(*) > 1
            )
      )
      WHERE RANK_N > 1
);

No comments :

Post a Comment