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 8368239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:20:22+00:00 2026-06-09T13:20:22+00:00

I have a search.jsp page where I search & retrieve a record from Database.

  • 0

I have a search.jsp page where I search & retrieve a record from Database. I have to duplicate this record and make modifications and save both records.

Ex:

 method1(){
  Response response=new Response();
  //To perform DB search
  response=delegate.requestSearch(//some request criteria);
  Types obj1=(Types) response.getBaseEntity();
  Types obj2=obj1;
  obj2.setPromaryKeyObject(//some unique value);
 }

In my DAO, save method:

session.save(obj1);
session.save(obj2);
transaction.commit(); // transaction

When the debug point commits transaction, I get one update query only. But I expect two insert queries.

But this works fine. This was an attempt but this is not what I want to do.

Types tempObj1 = new Types();    
tempObj1.setValue1(obj1.getValue1();
 // all values of the object should be set
session.save(tempObj1);
Types tempObj1 = new Types();    
tempObj2.setValue1(obj2.getValue1();
 // all values of the object should be set
session.save(tempObj2);
transaction.commit(); // transaction

In this case I trigger two insert queries.

I’m pretty sure that the mistake is in my hibernate method as I’m very new to Hibernate. This same code works fine when I was using JDBC and MySql queries.

  • 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-09T13:20:23+00:00Added an answer on June 9, 2026 at 1:20 pm

    This is due the obj2 == obj1. Try to obj2 = obj1.clone();

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

Sidebar

Related Questions

i have search at this websit : https://stackoverflow.com/search?page=2&tab=relevance&q=nsarraym%20objectatindex%20index%205%20beyond%20bounds%20for%20empty%20array%27 but the solve no suit me.
I have a simple search page with this text input form <form name=assetInput action=assetResult.jsp
I have an ASP.NET page that contains two div's. Both have search fields and
I have Json response from my database . I am using Php for this
I have the following form from http://regain.sourceforge.net/ : <form name=search action=search.jsp method=get> <p class=searchinput>
I have a JSP page which display a list from servlet, it has a
I have search functionality in my jsp page.. When user types abc and search
I get user list from database in jsp. In each user I have a
In my jsp application I have a search box that lets user to search
I have search through the web to figure this out but no luck. I

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.