-->
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.  [ 2 posts ] 
Author Message
 Post subject: unidirection many-many composite key with a list-index
PostPosted: Tue Jun 08, 2010 10:00 am 
Newbie

Joined: Thu Feb 11, 2010 7:54 am
Posts: 5
I am trying to model a many-many to relationship with a composite key and list index. I almost have this working but I can not seem to get/set list index property. It works as long as I do not set the list-index property.

I get the following error:
javax.naming.NamingException: Repeated column in mapping for com.loadgeneral.model.Scenario.scenarioModules column: LIST_POSITION

How else I am suppose to set and get the LIST-INDEX column?
Any help would be greatly appreciated Steve.

My hibernate mapping file.

<list name="scenarioModules" lazy="true" table="SCENARIO_MODULE" fetch="select">
<key column="SCENARIO_ID" />
<list-index base="1" column="LIST_POSITION"/>
<composite-element class="com.loadgeneral.model.ScenarioModule">
<parent name="scenario" />
<many-to-one name="childScenario"
column="child_scenario_id"
not-null="true"
class="com.loadgeneral.model.Scenario" />
<!--
This is does not seem to work.
<property name="listPosition" type="java.lang.Integer">
<column name="LIST_POSITION" not-null="true" />
</property>
-->
</composite-element>
</list>


Top
 Profile  
 
 Post subject: Re: unidirection many-many composite key with a list-index
PostPosted: Thu Jun 10, 2010 4:46 pm 
Newbie

Joined: Thu Feb 11, 2010 7:54 am
Posts: 5
I guess you don't need the list-index java attribute. Hibernate populates list-index position based on the element's position in the array. This is a neat feature. It seems I need to explicit set this attribute for non-composite elements.

Steve


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