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

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.

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

Reply via email to