2009/4/6 Lars Helge Øverland <larshe...@gmail.com>: > > > 2009/4/6 Bob Jolliffe <bobjolli...@gmail.com> >> >> I am not sure if I understand all of this correctly but it seems that >> if we use (as we do): >> <generator class="native"/> >> >> then hibernate will delegate to 'identity' for h2 and mysql (and >> probably 'sequence' for postgres). Derby for some peculiar reason >> delegates to 'hilo'. >> >> Presumably we could fix this by making generator class="identity" but >> that then maybe breaks postgres which is not an option. Or do we have >> to patch the dialect? again. >> >> I haven't really got my head around "hilo" but it looks like a pain. >> >> Any thoughts? > > > It looks as Hibernate chose to use the hi-lo generator over identity since > the method for retrieving generated id's is a little weird in derby: > > http://opensource.atlassian.com/projects/hibernate/browse/HHH-1915
Yes I saw this too. Trying to follow the thread through https://issues.apache.org/jira/browse/DERBY-1518 it looks like the derby dialect initially shipped with native reesolving to identity, it caused problems so the hibernate folk changed it to return hilo. Following the thread further https://issues.apache.org/jira/browse/DERBY-2631 it seems that the identity "weirdness" problems were resolved. > DerbyDialect (which extends DB2Dialect) source code: > > http://viewvc.jboss.org/cgi-bin/viewvc.cgi/hibernate/core/trunk/core/src/main/java/org/hibernate/dialect/DerbyDialect.java?revision=15157&view=markup > > > This makes working with direct JDBC complicated... Workarounds I can think > of > > 1) Modify the getNativeIdentifierGeneratorClass() method in the DerbyDialect > to return IdentityGenerator.class. But this might break lots of things in > Hibernate. Which means I think that this should be ok. Don't know why nobody has done it yet though. I can have a go at patching it and see if the hibernate test suite all runs ok. If nothing else I'll learn a bit more about hibernate :-) Regards Bob > 2) Implement and use our own id generator in DHIS 2. > > 3) Use a startup routine in DHIS 2 (or modify the Dialect if possible) to > make all primary key columns "GENERATED BY DEFAULT". This implies that Derby > will accept input values for this column, as well as generating one when a > value is omitted or "DEFAULT" is supplied as value. > > > Which one sounds less hacky? Any better ideas? > > _______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp