0

Still a n00b in NHibernate :(

I want to add a composite index to the hbm.xml of one of my POCOs, for performance purposes. It does not relate directly to a class, but rather two common values I will be querying against.

I think I need to do a <map></map> entry in the XML, but the XSD is asking for a class name on the composite-key element, and there is no direct relationship, per se... plus it's asking for more information than I think I would need to provide. How do I do this?

    <map name="PropertyKeys">
        <key>
            <column name="StockID" />
            <column name="PropertyName" />
        </key>
            <composite-index class="Something?">
                <key-property name="What goes here?" />
            </composite-index>
        <what else goes here?>
    </map>
James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Jeremy Holovacs
  • 22,480
  • 33
  • 117
  • 254

1 Answers1

2

Have you read this http://ayende.com/blog/4045/nhibernate-mapping-map It explains when you would use a map and further on it explains the composite-index

However without more background info it is not 100% certain that you need a map!

Rippo
  • 22,117
  • 14
  • 78
  • 117
  • From what I understand, this is creating a key for an entity. Am I misunderstanding? I just want an index created on two columns, and I want to use that index when invoking my repository to look for certain small groups of values, not a unique value. – Jeremy Holovacs Mar 06 '12 at 12:44
  • 1
    I am the one who is misundertanding your question. Does this help http://stackoverflow.com/questions/834565/how-to-create-a-multi-column-index-or-unique-constraint-with-nhibernate – Rippo Mar 06 '12 at 13:13
  • that was it exactly. It'd be great if they used the proper names for things. Google is not a mind reader. :) – Jeremy Holovacs Mar 06 '12 at 19:25