SQL index on list column of NHibernate list?

I have two C # classes, say Container

and Item

, and a one-way communication:

class Container {
   [...]
   public IList<Item> Items {get;set;}
}

      

NHibernate mapping looks like this:

<class name="Container">
  [...]
  <list name="Items" cascade="all-delete-orphan">
    <key column="ContainerId"/>
    <index column="Position"/>
    <one-to-many class="Item"/>
  </list>
</class>

      

As a result, NHibernate (2.0.1) generates a column ContainerId

in the table Item

. Since I usually move this join from the side Container

, I want to put the SQL index on the column ContainerId

. NHibernate doesn't seem to provide a mapping syntax for this, or at least it's not obvious to me. What's the best way to speed it up?

I would like to keep this from spreading to multiple places, so I would rather change only the mapping file. Is there a way to do this in NHibernate syntax? Should I embed custom SQL commands? If so, how?

+2


source to share


2 answers


Look at the display <database-object>

; this will allow you to create arbitrary indexes, triggers, etc. as part of the schema creation process. The usage is described in this article .



+2


source


I don't know if and when this changed, but it can be done using



<index>
    <column name="Position" index="Positionindex" />
</index>

      

0


source







All Articles