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
|