[hibernate-dev] Oracle12cDialect identity support
Emmanuel Bernard
emmanuel at hibernate.org
Thu Dec 24 05:57:59 EST 2015
I think my preference would be to override in Oracle*Dialect getNativeIdentifierGeneratorClass so that it always returns SequenceStyleGenerator
1. it would be backward compatible with the logic we had for ever (with the exception of 5.0 but I understand that it is not really reliable)
2. I suppose sequences are still the preferred choices for Oracle DB DBAs.
Emmanuel
> On 24 Dec 2015, at 02:46, Gail Badner <gbadner at redhat.com> wrote:
>
> Oracle12cDialect was added in 5.0 by HHH-9044. Unfortunately there are
> problems with the new identity support that Oracle12cDialect introduced
> (HHH-9983). The fix for HHH-9983 involved SPI changes, so it was applied to
> master for 5.1 (only).
>
> A couple of weeks ago, Andrea found that identities seemed to work using
> 5.0 when running BulkManipulationTest using Oracle JDBC 12.1.0.1.0. At the
> same time it failed for me in the same way as HHH-9983 using 12.1.0.2.0.
> Then Andrea and I switched the JDBC versions (Andrea tried 12.1.0.1.0; I
> tried 12.1.0.2.0) and we were both able to run BulkManipulationTest
> successfully. This was very strange, especially since we were using the
> same Oracle instance, each using a different user. I didn't see any
> difference in how we were setting Hibernate properties. Several days later,
> I tried Oracle JDBC 12.1.0.2.0 again, but BulkManipulationTest was failing
> again in the same way as HHH-9983.
>
> Does anyone know how to get Oracle12cDialect's identity support to work for
> 5.0 reliably? Is there some version of Oracle JDBC or DB configuration that
> is required?
>
> If so, please let me know. The rest of this email assumes it is not
> possible. If I'm missing some configuration detail, then just ignore the
> rest of this message.
>
> When the unit tests are run using Oracle12cDialect on 5.0, there are many
> failures:
> * tests with entities explicitly mapped to use an identity fail; these
> failures did not happen in 4.3 using Oracle10gDialect because these tests
> where skipped (because Oracle10cDialect#supportsIdentityColumns returns
> false)
> * use @GeneratedValue with default strategy or use hbm mapping for ID
> <generator class="native"/>; these failures did not happen in 4.3 because
> the native generator for Oracle10gDialect uses a sequence; the native
> generator for Oracle12cDialect uses an identity.
>
> Also, starting in 5.0, when using Oracle 12c, StandardDialectResolver will
> automatically resolve to Oracle12cDialect if the dialect is not explicitly
> mapped. Previously it would have resolved ot Oracle10gDialect.
>
> I would be OK with changing the native generator in 5.0 from sequence to
> identity if identities were working properly. I think it will cause
> confusion when applications break. To get things working with 5.0,
> applications will need to explicitly set the dialect to Oracle10gDialect,
> extend Oracle12cDialect to disable identity support, or change ID mappings
> to specify sequences.
>
> Here are some alternatives to get things working.
>
> Alternative A:
> 1) for 5.0 through 5.x override Dialect#getNativeIdentifierGeneratorClass
> to return SequenceStyleGenerator.class; I suggest the change for 5.x
> because I don't think it would be an acceptable to change the native
> generator for Oracle12cDialect from using a sequence to using an identity
> in 5.x;
> 2) for 5.0 only, remove support for identities;
> 3) for 6.0, if desireable, extend Oracle12gDialect (or whatever is current
> at that time) to change the native generator to use an identity.
>
> Alternative B:
> 1) for 5.0 through 5.x, leave Oracle12cDialect as is, and add a new dialect
> with native generator that uses a sequence (i.e.,
> Oracle12cNativeSequenceGeneratorDialect or something else that is not so
> ugly);
> 2) for 5.0 through 5.x, change StandardDialectResolver to automatically
> resolve to Oracle12cNativeSequenceGeneratorDialect for Oracle 12g server.
>
> Alternative C:
> 1) for 5.0 through 5.x, change native generator for Oracle12cDialect to use
> sequence; leave identity support as is (broken in 5.0; fixed in 5.1);
> 2) for 5.0 through 5.x, add a new dialect with native generator that uses
> an identity (Oracle12cNativeIdentityGeneratorDialect or something else that
> is not so ugly).
> 3) change StandardDialectResolver to automatically resolve to
> Oracle12cDialect for Oracle 12g server.
>
> I prefer alternative A. Alternatives B and C involve maintaining 2 dialects
> for the same Oracle version; I would think that one of them would be
> deprecated moving forward.
>
> Thoughts?
>
> Thanks,
> Gail
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
More information about the hibernate-dev
mailing list