Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8558961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:55:50+00:00 2026-06-11T15:55:50+00:00

In my application I have a component that receive objects from another components and

  • 0

In my application I have a component that receive objects from another components and insert them to MySQL DB. Currently I’m buffering the objects and once in a while (few seconds) the objects are inserted to the DB using a batch (using JDBC, not hibernate).

I would like to break this objects to 2 objects, then two buffers, and finally insert them to 2 different tables.

My first thought was to use MySQL auto generated ID to tie the two sub-objects together in the table (as foreign key).

My problem is – how will I know the auto-generated ID for the ‘father’ object when I insert the ‘child’ object?

My ideas are:

  1. Generate my own ID before splitting the object and send the ID to the DB myself, without using MySQL auto-generated ID.
  2. Use stored procedure that will insert the first object, use MySQL’s LAST_INSERT_ID();

What do you think?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:55:51+00:00Added an answer on June 11, 2026 at 3:55 pm

    Your essential problem is that you need information from the database for one object before you can store the other object.

    Let’s say you split your compound object into two smaller objects, namely Place and Map.

    If you must have two buffers to store Place and Map, then I see three ways of doing so:

    1. Put only Place in the store-buffer. When Place is stored, and the PK has been read from the database, ONLY THEN place Map in the other store-buffer.

    2. Put Place and Map in their own store-buffers. When a Map is about to be stored, check it’s associated Place, to see if the PK has been generated yet. If it has, then store the Map. If it hasn’t, then skip that Map and check the next Map.

    3. Put Place in the store-buffer. When it gets stored, read the PK, and immediately store the Map also. This obviously does not use two store-buffers.

    Look at how other objects are stored in your application. Certainly they don’t generate their own IDs before they are stored in the database. Certainly you don’t try to put them in a store-buffer before you have all the information necessary to store them. My recommended course of action is therefore option 1 or 3.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that requires resizing of a component that will be scaled
I have installed my windows application that uses TeeChart ActiveX (a COM Component for
I have a .NET application that contains a checkbox (System.Windows.Forms.Checkbox). This component (WindowsForms10.BUTTON.app.0.378734a1) is
In my application, I have several components that have to know about each other,
I have an application that called several other .exe components written in delphi. The
I have a Delphi 6 application that uses the Indy 9 components to maintain
I have a web application on ASP.NET (C#) that has some precompiled components. I've
I am writing a Java Swing application that needs to have a window receive
I have a Delphi 6 application that receives and processes an image stream from
I have to use functionality that is in another application domain. The result should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.