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.  [ 2 posts ] 
Author Message
 Post subject: problem with columns used in multiple indexes
PostPosted: Tue May 20, 2008 9:49 am 
Newbie

Joined: Fri Jun 08, 2007 10:20 am
Posts: 1
There seems to be a problem with mapping multiple indexes for a column, for example when adding indexes for optimisation into the hbm file.

Both Hibernate version 1.2.0.GA and 2.0.0.Alpha1 are affected

For example
Code:
<property name="Prop" type="int" >
  <column name="Prop" not-null="true" unique-key="IDX_Prop" index="IDX_PropData, IDX_PropData2"/>
</property> 


It's caused by NHibernate.Cfg.HbmBinder calling StringTokeniser in such a way that it returns the delimiters. These commas/spaces are interpreted as new index names and naturally cause invalid database scripts.

It can be simply resolved in 1.2.0.GA in NHibernate.Cfg.HbmBinder.BindIndex and BindUniqueKey by passing false to the StringTokenizer's returnDelims parameter:
Code:
      private static void BindIndex(XmlAttribute indexAttribute, Table table, Column column, Mappings mappings)
      {
         if (indexAttribute != null && table != null)
         {
            StringTokenizer tokens = new StringTokenizer(indexAttribute.Value, ", ", false);
            foreach (string token in tokens)
            {
               table.GetIndex(token).AddColumn(column);
            }
         }
      }

      private static void BindUniqueKey(XmlAttribute uniqueKeyAttribute, Table table, Column column, Mappings mappings)
      {
         if (uniqueKeyAttribute != null && table != null)
         {
            StringTokenizer tokens = new StringTokenizer(uniqueKeyAttribute.Value, ", ", false);
            foreach (string token in tokens)
            {
               table.GetUniqueKey(token).AddColumn(column);
            }
         }
      }


and similarly in 2.0.0.Alpha1 by equivalent changes to the abstract ClassBinder and the ClassIdBinder and CollectionBinder

Would a patch file for this be useful?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 20, 2008 8:35 am 
Newbie

Joined: Fri Jun 20, 2008 8:24 am
Posts: 7
Hello,
I've downloaded the latest build from svn today, but this problem still exists. Are you going to fix it in future builds?


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

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.