This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Cascading non foreign key to Child Table

 
Ranch Hand
Posts: 101
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a parent table, t_books_category and a corresponding child table T_Book with a 1-n mapping. My configuration files for the two tables are as under:

Mapping for T_BOOKS table



Mapping for T_BOOKS_CATEGORY





As you can see I have been able to map the foreign key attribute of cat_id. However there is one further requirement, there is an additional column cat_Date which is also present in the child table and both values will be the same. However this field is a non key field in both the tables. How do i perform the mapping for this column such that save and update on the master table is cascaded to the child table too.

Thank you and I would appreciate any help.

 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate is not going to replicate denormalized data for you unfortunately. You'll need to keep these updated manually (or implement a trigger to do it).
 
Stanley Walker
Ranch Hand
Posts: 101
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Paul. I can achieve what I was trying out programmatically, I was just wondering if hibernate can do the same.
 
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate has something called as dynamic-updates and dynamic-inserts.
If the child objects are loaded and if you are updating the category date in category, then when you change the category date in books hibernate automatically detects a change in value and fires a update query only to update the specified column.

Now I know that this feature directly works on the object, but I'm not sure if it works on the children associated with the object. You might want to try it.
This wouldn't work if you dates are generated automatically by the database.
 
You get good luck from rubbing the belly of a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!