• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help with hibernate

 
Jay Richards
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i make a mapping property (lpos) to become incremental by not using id because i already have an id that is assigned but i need another property to be incremental. making lpos an id will throw an duplicate id constraint error.

this existing can save my data up to the 2nd level. but i cannot load it properly because lpos is always zero (0), but when i edit the records directly can modify the lpos 0..N respectively, i can load the record properly. please help. thx...



how can i make property ipos be incremental from 0..N...
[ January 25, 2006: Message edited by: Jay Richards ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You use a Key Generation Strategy (like autoincrement) for primary keys. It doesn't really apply to non-key properties. Why not just increment your propery as part of your update code?
 
Jay Richards
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why is it so hard to do list mapping

do you really have to manage ng key column, because the values of lpos should be 0..N, assuming you have to records, so lpos would 0 and 1, i tried changing the database to autoincrement, the values has been 8 and 9 for example, and hibernate will load an extra 7 empty objects beside the real 2 records..

is that how he treats the key column, should always be 0... N (size of the child)?

need help in correct usages of the list mapping. (

thanks.
 
Chris Richardson
author
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jay,

I can't quite tell what you trying to do here but what happens if you

A. change each <list> mapping to:

<list name="collections" lazy="true"
cascade="all">
<key column="gcId"/>
<index column="lpos" />
<one-to-many class="billing.collections.GCCollection" />
</list>

i.e. remove the inverse="true" since I don't see the inverse relationship defined and remove the redundant table=".."

B. Either remove each:

<property name="lpos"/>

Or change each one to:

<property name="lpos" insert="false" update="false"/>

Hibernate will then maintain the list ordering in lpos.


Chris
 
Jay Richards
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks. its working now
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic