Uploaded image for project: 'Hibernate ORM'
  1. HHH-1672

DatabaseMetadata.isSequence should check for usage of catalog/schema in key

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Rejected
    • Affects versions: 3.1.3
    • Fix versions: None
    • Components: hibernate-core
    • Labels:
      None
    • Environment:
      WinXP SP2, JDK 1.5.0_06
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

      DatabaseMetadata.isSequence checks whether a key, passed in from methods in Configuration is present in the sequences collection.
      The key istelf is created using the values for default schema/catalog so a key will have the form "schema_name.hibernate_sequence".
      The entries in the collection are obtained from the database, and in the case of Oracle at least, are returned with no schema information
      in the name and so will have the form "hibernate_sequence".

      The lookup obviously fails as a result.

      Since the generation of the sequence key is under control of Hibernate, I think it would be safe to assume that the key passed to the method
      would include the schema name. As a result, a treatment similar to that given to tables in isTable(...) should be given and the key should be
      parsed to split optional schema/catalog values from the sequence name and then look up the name in decreasing strictness as in the following
      code fragment:

      [code]
      public boolean isSequence(Object key) {
      if ( key instanceof String) {
      String lcKey = ((String)key).toLowerCase();

      if ( sequences.contains(lcKey)) return true;

      String[] strings = StringHelper.split(".", lcKey);
      if(strings.length==3)

      { // we have catalog and schema name. Since the full name did not match, check // for schema + seqName return sequences.contains(strings[1] + '.' + strings[2]); }

      else if (strings.length==2)

      { // we have schema name in addition to the seqName. Since the full name did not match, check // for seqName only return sequences.contains(strings[1]); }

      }
      return false;
      }
      [/code]

        Attachments

          Issue links

            Activity

              People

              • Votes:
                3 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 1h
                  1h
                  Remaining:
                  Remaining Estimate - 1h
                  1h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified