• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Table per hierarchy update

 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i.
In my system, I have these two domain objects:

I use table per hierarchy strategry to map these objects to the database.
Also, I have DAO classes built on Spring's Hibernate facility.

In order to edit a credit card info, I load it first from the database
and set it in the session scope, then I forward the request to a JSP form.
Upon form submittion, I call:
billingDetailsDao.update(creditCardObject);
The problem is that the generated SQL by Hibernate only updates the fields
of BillingDetails object.
Any ideas how to over come this?
Thanks.
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My guess on what is happening is that hibernate is getting using the BillingDetails mapping file to persist your object to the database because of the method signature on your method.

public void update(BillingDetails billingDetails)

Try and make a new method that will accept a CreditCard and persist it.

If the same thing happens their might be an issue with your mapping files.

Have you written a unit test to see if you're able to persist a credit card object by itself?


Also, I wouldn't store your business objects in your http session.

I think the following works better.

Request 1.

Get the credit card information from the database by id.
Store that credit card in your http request object.
Get the credit card from the http request in your jsp and display it.
Having a hidden field in your form with the credit card's id.

Request 2

Get the credit card information from the database by the hidden id value.
update that credit card with all the form data.
persist the credit card.

It might seem like a lot of extra work, but we've had a lot of success with this design.

Best of Luck.
 
I'm doing laundry! Look how clean this tiny ad is:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic