Uploaded image for project: 'Crowd Data Center'
  1. Crowd Data Center
  2. CWD-2397

JIRA importer Queries are broken against MySQL

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Low
    • 2.2.7, 2.3
    • 2.2.2
    • Import & Export
    • None
    • MySQL 5.x

    Description

      Problem 1:

      • Name in uppercased for "CWD_DIRECTORY" causes issues in DBs with lowercased table names:
        org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [SELECT id, directory_name FROM CWD_DIRECTORY WHERE directory_type = 'INTERNAL']; nested exception is java.sql.SQLException: Table 'jira4.CWD_DIRECTORY' doesn't exist
        at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:220)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:407)
        

      Problem 2:

      • Ambiguity in the Membership Query:
        Cause :
        org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [SELECT usr.user_name AS user_name, grp.group_name as group_name FROM cwd_membership AS mem INNER JOIN cwd_group AS grp ON mem.parent_id = grp.id INNER JOIN cwd_user as usr ON mem.child_id = usr.ID WHERE membership_type = 'GROUP_USER' AND directory_id = ?]; Column 'directory_id' in where clause is ambiguous; nested exception is java.sql.SQLException: Column 'directory_id' in where clause is ambiguous
        Stack Trace :
        org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [SELECT usr.user_name AS user_name, grp.group_name as group_name FROM cwd_membership AS mem INNER JOIN cwd_group AS grp ON mem.parent_id = grp.id INNER JOIN cwd_user as usr ON mem.child_id = usr.ID WHERE membership_type = 'GROUP_USER' AND directory_id = ?]; Column 'directory_id' in where clause is ambiguous; nested exception is java.sql.SQLException: Column 'directory_id' in where clause is ambiguous
        at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:100)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
        

        I fixed the problem adding "mem." to the "WHERE" conditions:

        SELECT usr.user_name AS user_name, grp.group_name as group_name FROM cwd_membership AS mem INNER JOIN cwd_group AS grp ON mem.parent_id = grp.id INNER JOIN cwd_user as usr ON mem.child_id = usr.ID WHERE mem.membership_type = 'GROUP_USER' AND mem.directory_id = ?;
        

      More details and full stack traces: https://support.atlassian.com/browse/CWDSUP-4676

      Attachments

        Issue Links

          Activity

            People

              jwalton joe
              rbattaglin Renan Battaglin
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: