Back Forum Reply New

HOW to insert data to more than one tables using one form

Hi, I am new to Spring framework.

I have a case I couldn't solve my self. I have two POJO, ie: PersonData and Address. Both of this POJO save on separated table on a database. I mapped both of the POJO to the database tables using Hibernate.

My problem is how to store the POJOs data(PersonData and Address) to relevant tables using one form.

I recommend you learn more about Hibernate... that is part of it's basic functionality.

Don't map the form bean directly to the DB.

One bean to represent form data
Two beans to represent table data
Code in the controller/service to move data between the objects.

Have a single command object to get details from form to your POJO, then retrieve these values and using hibernate session, use one of the save/ saveorupdate method to persist to DB.
¥
Back Forum Reply New