• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate: Updating version in child records  RSS feed

Jim Cross
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my test application, I have two tables; J_TRADE and J_CASHFLOW. Trades may have zero-to-many associated cashflows.

J_TRADE has ID as its primary key, and a version column.
J_CASHFLOW references the trade ID column and the trade VERSION column.

The mappings are as follows:

Clearly from this, the cashflow class isn't aware that it references the trade version. So, while the cashflow trade id does get populated correctly on insert, the cashflow trade version doesn't.

Is there any way to make the cashflow reference the trade version, without making ID and VERSION a composite key in the trade table, and having to handle the trade id and version increments myself?
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!