Help coderanch get a
new server
by contributing to the fundraiser
  • 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

Updating multiple tables while creating the application

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

When I create an application, two tables have to be updated.

I have two tables with the columns given below.

Table-1: APPLICATIONS

Columns:

AP_ID -> PK (I use the APP_SEQ to get the next sequence id)
INITIAL_SUB_ID ->(This will be the PK of SUBMISSIONS Table. When I create the APPLICATION, I use SUB_SEQ to get the next sequnce id and insert a record into both APPLICATIONS and SUBMISSIONS Table)
APP_NUMBER etc..

Table-2: SUBMISSIONS

Columns

SUB_ID->PK
APP_ID->FK(Primary key of APPLICATIONS Table)
SUB_TITLE Etc..

1. When I create the application, I will be updating both APPLICATIONS, SUBMISSIONS Table(Currently I have a view which updates both the tables.)
2. When I create the submission, I will be updating only submissions table as the submission can be created for any of the existing application.


Question: I am planning to replace JDBC with Hibernate. I would appreciate, If any body can help/throw a suggetion for creating mapping file in the above scenario.

Thanks,
Konda Golamaru.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure what the initial sub id in Application is for. If it is just which was the first Submission record added, then make that a OneToOne mapping. In regards to the Submission having Many records to One Application sounds like a OneToMany/ManyToOne relationship.

Check out the Hibernate documentation at www.hibernate.org for exact mapping details.

Good Luck

Mark
 
Konda Golamaru
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

Thanks for your reply.

I don't see the use of Initial Submisson Id being present in Applications table. Any way, The database was created 7 years ago and still we are using the same schema.

Coming back to the mapping, I think as you suggested, I need to more read on One to Many or Many to One mappings as The application can have multiple submissions/Multiple submissions can be created for a single application.

Thanks for your time.

Konda Golamaru.
 
What I don't understand is how they changed the earth's orbit to fit the metric calendar. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic