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

  • Home
  • SEARCH
  • 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 7666411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:49:34+00:00 2026-05-31T14:49:34+00:00

I have a table with four columns, say P_Key(int), Ref_Key(int), Key(String), Value(Integer). I want

  • 0

I have a table with four columns, say

P_Key(int), Ref_Key(int), Key(String), Value(Integer).

I want to avoid multiple create statements by persisting a map along with Ref_key into this database. Map contains keys and corresponding value.It will create multiple row for that Ref_key using entries from the map.I am using hibernate.

Suppose, I want to persist following map :

"Me" -> 0
"You" -> 10
"They" -> 12

and Ref_Key is 123.

Then it should create 3 rows into table.

P_Key Ref_Key Key Value
1      123    "Me" 0
2      123    "You" 10
3      123    "They" 12

Assuming that key starts with 1 and is auto-incremented.

What is the approach that I should follow?

  • 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-05-31T14:49:35+00:00Added an answer on May 31, 2026 at 2:49 pm

    If you mean “insert statements” instead of “create statements“; I am not sure you can: a database has to receive 3 INSERTs for adding 3 lines in the database. But Hibernate should merge them and send only 1 network request (batching of requests).

    The approach I suggest:

    • Create an @Entity with the table format.
    • Create one instance of your entity for each element of your map.
    • Simply persist all the instances.
    • Close your transaction (I mean flush).

    See http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/batch.html for more information about batching. NOTE: Unfortunately, Hibernate disables the batching for the auto incremented primary keys!

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

Sidebar

Related Questions

I have a table with four columns: PartNumber, ValvePartNumber, ActuatorPartNumber, Price I want to
I have a table with four Columns: Col1, Col2, Col3, and Col4. Col1, Col2,
I have four tables containing exactly the same columns, and want to create a
I have a table with two columns, customer id and order. Let's say I
I have a table with four columns: Account#, Card#, CardNameType and Cardholder's Name. The
I have a table of four columns. The data in the first column is
I have a table with four columns, where col1 & col2 contain similar values
I am a student this is homework... I have one table with four columns:
I have a MySQL table with four columns, submited_name, submited_URL, submited_type, uniqueID . In
I have DB table defined with four columns: short, controller, action, id And using

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.