• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Table per hierarchy update

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • 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.
 
Nathan Hook
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic