We're updating the issue view to help you get more done. 

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

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

Environment

WinXP SP2, JDK 1.5.0_06

Status

Assignee

Unassigned

Reporter

Bonny Rais

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Time Tracking

1h

Components

Affects versions

3.1.3

Priority

Major