Addressing Error: Request processing failed; nested exception is org.hibernate.NonUniqueResultException: query did not return a unique result: # When Modifying Artifact Permissions

Be sure to take a backup of the Datameer MySQL database before doing the following steps:

  • First, run the following MySQL query on the Datameer database:
SELECT dap_file.id, dap_file.name, dap_file.extension, foo.total, foo.permission__id FROM (SELECT COUNT(*) total, permission__id FROM group_permission GROUP BY permission__id ORDER BY total DESC) foo JOIN dap_file ON dap_file.permission_fk = foo.permission__id WHERE foo.total > 1; 
  • This query outputs all artifacts with multiple groups assigned. For example, you might receive the following result:
mysql> SELECT dap_file.id, dap_file.name, dap_file.extension, foo.total, foo.permission__id FROM (SELECT COUNT(*) total, permission__id FROM group_permission GROUP BY permission__id ORDER BY total DESC) foo JOIN dap_file ON dap_file.permission_fk = foo.permission__id WHERE foo.total > 1;
+------+----------------------+--------------------+-------+----------------+
| id   | name                 | extension          | total | permission__id |
+------+----------------------+--------------------+-------+----------------+
|  686 | Clickstream Analysis | WORKBOOK_EXTENSION |     2 |            883 |
| 1012 | Ravi_Pivot_9304      | WORKBOOK_EXTENSION |     2 |           1293 |
+------+----------------------+--------------------+-------+----------------+
2 rows in set (0.00 sec)
  • From this output, identify the workbook in question and note the permission__id value.
  • Then run the following query on the permission__id:
mysql> SELECT * FROM group_permission WHERE permission__id = <permission__id>; 
  • Running this in this example from above on permission__id = 1293 yielded the following:
mysql> SELECT * FROM group_permission WHERE permission__id = 1293;
+----+-------------+-----------------+----------------+
| id | group_name  | permission_bits | permission__id |
+----+-------------+-----------------+----------------+
|  7 | SecondGroup | R__             |           1293 |
| 16 | Testgroup   | R__             |           1293 |
+----+-------------+-----------------+----------------+
2 rows in set (0.00 sec)

You need to remove erroneous entries from this table. For example, to remove the group Testgroup, run:

mysql> delete from group_permission where id = 16; 

Follow these steps to clean up the erroneously added groups to the workbook.