-->
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: How to get table index created on many-to-many entity
PostPosted: Mon Nov 28, 2005 8:15 am 
Newbie

Joined: Tue May 24, 2005 6:51 am
Posts: 5
Hi all,

I'm trying to get hibernate to generate at least one index on a many-to-many association entity. I have users registering on a web site and selecting one of a set of possible answers for each question posed on the registration form. The effected entities are RegistrationProfiles and PossibleAnswers.

Hibernate successfully generates DDL to create an association table called SelectedAnswers with two columns: PossibleAnswerId and RegistrationProfileId. Now I just like to have it generate an index on the two.

I've tried Collection-Key and Key Column tags but they don't create indexes on the association table.

Thanks for the help.

Regards,
Stefan Mahs




Hibernate version:
3.0.5

Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
<class
name="com.media24.userprofile.model.RegistrationProfile"
table="tb_ur_RegistrationProfiles"
>

<id
name="id"
column="RegistrationProfileId"
type="java.lang.Integer"
unsaved-value="-1"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-RegistrationProfile.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
.
.
.
.
<bag
name="answers"
table="tb_ur_SelectedAnswers"
lazy="true"
cascade="all"
order-by="DisplayOrder"
>

<key
column="RegistrationProfileId"
>
</key>

<many-to-many
class="com.media24.userprofile.model.PossibleAnswer"
column="PossibleAnswerId"
outer-join="auto"
/>

</bag>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-RegistrationProfile.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>



<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
<class
name="com.media24.userprofile.model.PossibleAnswer"
table="tb_ur_PossibleAnswers"
>

<id
name="id"
column="PossibleAnswerId"
type="java.lang.Integer"
unsaved-value="-1"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-PossibleAnswer.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
.
.
.
.
<bag
name="registrationProfiles"
table="tb_ur_SelectedAnswers"
lazy="true"
inverse="true"
cascade="all"
>

<key
column="PossibleAnswerId"
>
</key>

<many-to-many
class="com.media24.userprofile.model.RegistrationProfile"
column="RegistrationProfileId"
outer-join="auto"
/>

</bag>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-PossibleAnswer.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


Name and version of the database you are using:
MS SQLServer2000


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.