Modeling an associated class as an ordered list?

Discuss the Hibernate cartridge here

Postby joelkoz » Tue 16. Aug 2005, 20:39

More info on this topic:

Two revealing posts from the Hibernate forum:

http://www.hibernate.org/193.html

and

(if you are using Hibernate 3):
http://forum.hibernate.org/viewtopic.ph ... =listindex

Also, I believe there is a bug in this "ordered list" feature of the AndroMDA Hibernate Cartridge. Some additional code needs to be generated. Per the FAQ reference above (at http://www.hibernate.org/193.html )....

Assume I've set the namespace property associationEndCollectionIndexName to the value of "listPosition".

If using Hibernate 2, the following additional code would need to be generated in the child entity's Java classes IF doing a bi-directional, one-to-many, ordered association:

Code: Select all

private int listPosition;

public int getListPosition()
  {
    return this.get<nameOfParentEntity>().get<nameOfThisEntityInParent>().indexOf(this);
  }

  private void setListPosition(int index)
  {
    // not used, calculated value, see getIndex() method
  }
  ...



Also, the "listPosition" attribute would need to be added to the child entity's Hibernate HBM file.

For Hibernate 3, the following change would be needed:

in the parent entity's HBM file, where the <list> mapping is, the "inverse" attribute should be set to FALSE (it is currently set to "true").

in the child entity's HBM file, where the <many-to-one> mapping is, the attributes "update" and "insert" both need to be set to false.

If I can figure out how to make a patch, I may submit the fix. Otherwise, can the person who works on the Hibernate cartridge make this fix?
Last edited by joelkoz on Tue 16. Aug 2005, 20:45, edited 2 times in total.
joelkoz
AndroMDA Developer
 
Posts: 166
Joined: Wed 15. Jun 2005, 15:45
Location: Indianapolis, IN

Postby chad.brandon » Tue 16. Aug 2005, 20:43

Otherwise, can the person who works on the Hibernate cartridge make this fix?


File a JIRA issue and I'm sure Carlos will take care of it (but of course a patch is always nice :))
Chad Brandon - chad [at] andromda [dot] org
http://www.andromda.org
chad.brandon
AndroMDA Admin
 
Posts: 3053
Joined: Fri 6. May 2005, 20:26
Location: Colorado Springs, CO, USA

Postby joelkoz » Wed 24. Aug 2005, 16:10

I THINK I've got this one solved, and have submitted a patch to JIRA. Its my first patch, so any constructive criticisms are welcome. I want to make sure I'm doin' it right! :D
joelkoz
AndroMDA Developer
 
Posts: 166
Joined: Wed 15. Jun 2005, 15:45
Location: Indianapolis, IN


Return to Hibernate cartridge

Who is online

Users browsing this forum: No registered users and 0 guests