eclipse-ee4j / glassfish

Eclipse GlassFish
https://eclipse-ee4j.github.io/glassfish/
378 stars 143 forks source link

TopLink should provide parallel support for SEQUENCE and IDENTITY at the same time #2021

Closed glassfishrobot closed 16 years ago

glassfishrobot commented 17 years ago

@GeneratedValue allows a programmer to specify, what type of generation strategy the platform shall use: Using a database TABLE, using a database SEQUENCE (a.k.a external generator), using an IDENTITY column (a.k.a internal generator), or let the platform decide (AUTO).

Currently toplink doesn't make a difference of SEQUENCE and IDENTITY. Some database systems provide both, SEQUENCEs AND IDENTITY to exist at the same time. So TopLink should take respect of the programmer's decision and follow exactly the specified sequence: SEQUENCE should use SEQUENCE, IDENTITY should use IDENTITY, AUTO should ask the platform implementation which one to use (since it might be database vendor specific, which one is better).

There are several platforms able to support this already, e. g. PostgreSQL, SQLAnywhere and DB2.

Environment

Operating System: All Platform: All

Affected Versions

[9.1pe]

glassfishrobot commented 6 years ago
glassfishrobot commented 17 years ago

@glassfishrobot Commented mvatkina said: resetting the default owner

glassfishrobot commented 16 years ago

@glassfishrobot Commented ailitche said: Summary of what was done:

1. Each platform now states whether it supports identity and whether it supports sequence objects - so a single platform may support both.

2. Whether the NativeSequence is sequence object or identity is decided onConnect depending on platform: NativeSequence got an extra boolean flag shouldUseIdentityIfPlatformSupports - we adhere to it in case the platform support is there, otherwise use whatever the platform supports (for instance, Identity is not supported on Oracle, so on Oracle it will be sequence object regardless of shouldUseIdentityIfPlatformSupports value).

3. A back door was left for support of identity-like behaviour on Oracle (using sequence objects and triggers) - that was requested by one of GF users: all they have to do is oraclePlatform.setSupportsIdentity(true) in session customizer and use IDENTITY generation type (that will reference seq. object with default seq. name SEQ_GEN_IDENTITY). If generator name is specified (without actually defining the generator) then it will be used as a sequence object name, so @GeneratedValue(strategy=IDENTITY) corresponds to sequence named "SEQ_GEN_IDENTITY" and @GeneratedValue(strategy=IDENTITY, generator="MY_IDENTITY") corresponds to sequence named "MY_IDENTITY".

4. NativeSequence creation in schemamanager was reworked: now instead of adding a new SequenceDefinition class for each platform supporting sequence objects (ie OracleSequenceDefinition) a single class SequenceObjectDefinition is used; all platform-dependent sql generation (creation/deletion/increment alter writers) moved to platforms.

5. For now added support for both Identity and sequenceObjects only to PostgreSQLPlatform - it would be easy to fix other such platforms using PostgreSQLPlatform as an example.

Fixed: Issue number: 2021 Obtained from: TopLink Submitted by: ailitche Reviewed by: TopLink team Changed classes: oracle.toplink.essentials.internal.databaseaccess.DatabasePlatform oracle.toplink.essentials.internal.databaseaccess.DatasourcePlatform. oracle.toplink.essentials.internal.databaseaccess.Platform oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.NonRelationshipAc cessor oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataConstants oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject oracle.toplink.essentials.internal.sequencing.SequencingManager oracle.toplink.essentials.platform.database.oracle.OraclePlatform oracle.toplink.essentials.platform.database.DB2Platform oracle.toplink.essentials.platform.database.DerbyPlatform oracle.toplink.essentials.platform.database.InformixPlatform oracle.toplink.essentials.platform.database.MySQL4Platform oracle.toplink.essentials.platform.database.PostgreSQLPlatform oracle.toplink.essentials.platform.database.SQLAnyWherePlatform oracle.toplink.essentials.platform.database.SQLServerPlatform oracle.toplink.essentials.platform.database.SybasePlatform oracle.toplink.essentials.platform.database.TimesTenPlatform oracle.toplink.essentials.sequencing.NativeSequence oracle.toplink.essentials.sequencing.StandardSequence oracle.toplink.essentials.tools.schemaframework.FieldDefinition oracle.toplink.essentials.tools.schemaframework.SchemaManager oracle.toplink.essentials.tools.schemaframework.SequenceDefinition oracle.toplink.essentials.tools.schemaframework.TableSequenceDefinition New class: oracle.toplink.essentials.tools.schemaframework.SequenceObjectDefinition Removed classes: oracle.toplink.essentials.tools.schemaframework.OracleSequenceDefinition oracle.toplink.essentials.tools.schemaframework.TimeTenSequenceDefinition Test classes changed: oracle.toplink.essentials.testing.tests.cmp3.advanced.EntityManagerJUnitTestSuit e oracle.toplink.essentials.testing.models.cmp3.advanced.Man oracle.toplink.essentials.testing.models.cmp3.advanced.Woman Test added: EntityManagerJUnitTestSuite.testNativeSequences

glassfishrobot commented 16 years ago

@glassfishrobot Commented ailitche said: Checked in a small correction to my fix checked in yesterday. Changed classes: oracle.toplink.essentials.platform.database.PostgreSQLPlatform oracle.toplink.essentials.tools.schemaframework.SequenceObjectDefinition

Two problems were corrected: PostgreSQLPlatform sequence objects ignoring schema and SequenceObjectDefinition.checkIfExist method throwing exception (when it shouldn't).

glassfishrobot commented 17 years ago

@glassfishrobot Commented Was assigned to tware

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA GLASSFISH-2021

glassfishrobot commented 17 years ago

@glassfishrobot Commented Reported by markuskarg

glassfishrobot commented 16 years ago

@glassfishrobot Commented Marked as fixed on Thursday, October 25th 2007, 7:24:40 am