-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Bug prevents a native-if-not-assigned custom generator
PostPosted: Sun Nov 23, 2008 4:45 pm 
Newbie

Joined: Sun Nov 23, 2008 4:09 pm
Posts: 3
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 ... 61fb220864

My 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>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.