-->
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.  [ 5 posts ] 
Author Message
 Post subject: Creating a DB index on a value-type map
PostPosted: Sat Sep 03, 2005 11:51 am 
Regular
Regular

Joined: Fri May 13, 2005 4:08 pm
Posts: 64
I have the map shown below in one of my entities:
Code:
      <map name="ResponsesSet" table="responses" lazy="true">
         <key column="evaluationId"/>
         <index type="string" column="varName"/>
         <element type="StringClob" column="response" length="8096"/>
      </map>

I really need the db that NHibernate creates from this mapping to have a clustered unique index created that includes the columns evaluationId and varName. This is simple to do in SQL Enterprise Manager after the db is created, but can NHibernate's mapping file express this so it's done automatically?

In general, I don't know how to get a unique constraint that includes more than one column. I know about <property name="..." unique="true"/>, but if I want the constraint to span more than one column, what can I do? I haven't been able to find this topic in the documentation.

Thanks in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 07, 2005 10:18 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Try this:
Code:
<key>
  <column name="evaluationId" unique-key="some_name" />
</key>
<index type="string">
  <column name="varName" unique-key="some_name" />
</index>
... etc ...


i.e. use <column> tag with unique-key attribute.


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Fri Sep 09, 2005 7:44 am 
Regular
Regular

Joined: Fri May 13, 2005 4:08 pm
Posts: 64
That did the trick. Thanks! And thank you so much for working so hard for us! NHibernate rocks.

Is a clustered index too SQL Server-specific to hope for a mapping notation to indicate it within NHibernate? That is the only thing lacking in the mapping you suggested.[/i]


Top
 Profile  
 
 Post subject: More than a constraint
PostPosted: Thu Dec 15, 2005 11:46 am 
Regular
Regular

Joined: Fri May 13, 2005 4:08 pm
Posts: 64
I just noticed that the code sergey suggested earlier in this thread is not quite what I was looking for. That hbm mapping generates a unique constraint across two columns, but not an index across those columns. I really need the columns to be indexed. How can the mapping file be changed for that?

I've looked in NH and Hibernate's documentation without finding any pages on how to use the <key> or <index> tags. I'm probably just looking in the wrong place.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 15, 2005 11:51 am 
Regular
Regular

Joined: Fri May 13, 2005 4:08 pm
Posts: 64
Ok, so I was able to find some documentation for it.

http://nhibernate.sourceforge.net/h2.0.3-docs/reference/html/toolsetguide.html

The following will accomplish my goal: change the unique-key attributes to index attributes. This actually had the effect of turning that unique constraint into a clustered, primary key index. Excellent.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.