DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: yuri
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.
DataNucleus Store RDBMS

SchemaTool prefixes indices with schema name

Created: 17/Jan/11 09:28 AM   Updated: 07/Aug/11 08:48 AM   Resolved: 23/Jan/11 11:49 AM
Component/s: SchemaTool
Affects Version/s: 2.2.2
Fix Version/s: 2.2.3, 3.0.0.m1

File Attachments: 1. Text File index.patch (0.4 kB)
2. Zip Archive (3 kB)
3. File Schema.sql (1 kB)

Environment: Ubuntu 10.04 64 bit

Datastore: PostgreSQL
Severity: Development

 Description  « Hide
When there is a @OneToMany between entities A and B, generated indices are prefixed with the schema name and the SchemaTool fails

The problem seems to be in DatabaseAdapter.getCreateIndexStatement(Index idx, IdentifierFactory factory) method. It calls IdentifierFactory.newDatastoreContainerIdentifier() which creates TableIdentifier() instead of IndexIdentifier.

IdentifierFactory.newIndexIdentifier() should probably be called, but the callsite does not have all required information to pass to this method.

Another thing is if DatabaseAdapter.getCreateIndexStatement() calls indexIdentifier.getFullyQualifiedName(), IndexIdentifier should override getFullyQualifiedName() to not include schema information.

Repro steps: Run SchemaTool on the attached test project

Sort Order: Ascending order - Click to sort in descending order
yuri added a comment - 17/Jan/11 09:30 AM
Attached the test and the corresponding incorrectly generated schema

Andy Jefferson added a comment - 17/Jan/11 09:56 AM
Workaround present of using DDL mode. Prefixing an index with schema name is actually necessary for many datastores (e.g Oracle)

yuri added a comment - 17/Jan/11 09:58 AM
This patch works for me but I don't believe it's a correct fix.

yuri added a comment - 17/Jan/11 10:21 AM
I agree on the Oracle part. Then indeed IndexIdentifier should be created instead of TableIdentifier, and IndexIdentifier.getFullyQualifiedName() should reflect the data store type. My patch is a hack.

Andy Jefferson added a comment - 23/Jan/11 11:49 AM
Postgresql seems to be the only RDBMS that doesn't allow schema name in the index name. SVN passes

Ray Hu added a comment - 07/Aug/11 08:48 AM
Microsoft SQL Server(version 2008 R2) cannot allow schema name in the index name either.