I have implemented a custom identifier generator that behaves like 'assigned' if the user specifies a pk, and like 'native' if not. The code is basically taken from this rejected patch:
http://opensource.atlassian.com/project ... e/HBX-1034
I tried using this in a unit test which uses hbm2ddl and my unit test fails because the create table statement that hbm2ddl creates does not put an 'autonumber' on my pk column. The reason is that org.hibernate.mapping.SimpleValue.isIdentityColumn (line 212) does a check for .equals(IdentityGenerator.class) instead of an instanceof comparison.
When I change that method as follows, my test passes:
Code:
return IdentityGenerator.class.isAssignableFrom(
IdentifierGeneratorFactory.getIdentifierGeneratorClass(identifierGeneratorStrategy, dialect));
Should I create a JIRA issue and a patch for this?
Seems like someone has stumbled across this before:
http://forums.hibernate.org/viewtopic.p ... 61fb220864My mapping file starts like this:
Code:
<class name="Concept" table="concept" batch-size="25">
<id name="conceptId" type="java.lang.Integer"
column="concept_id"
unsaved-value="undefined">
<generator class="org.openmrs.api.db.hibernate.NativeIfNotAssignedIdentityGenerator" />
</id>