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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:33:52+00:00 2026-06-15T12:33:52+00:00

I have an issue where an object that was updated outside of Hibernate (using

  • 0

I have an issue where an object that was updated outside of Hibernate (using MySQL Workbench) is not getting refreshed. What happens is that I do a call to the Hibernate application and check the value, then do an update to a value of the object using Workbench, save and check that the value is set and do another call in Hibernate after refreshing and still the old value is there. The object does gets resfreshed on the third call but I need this to happen straight away — I cannot afford to use old data in this instance.

Query q = session.createQuery("SELECT object(o) FROM PortedNumber o WHERE o.number = '" + agiRequest.getDnid() + "'");
List<PortedNumber> portedNumberList = q.list();
if (!portedNumberList.isEmpty()) {
   for (PortedNumber portedNumber : portedNumberList) {
      session.evict(portedNumber);
      session.refresh(portedNumber, LockOptions.READ);
      networkId = portedNumber.getNetwork().getId();
      logger.info("Number is ported to networkId = " + networkId);
      break;
   }
}

The value that I update is the ‘portedNumber.getNetwork().getId()’.
Any guidance would be most weclome

Thanks.

  • 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-15T12:33:54+00:00Added an answer on June 15, 2026 at 12:33 pm

    In Hibernate 3, we have merge() (in Hibernate 2, use saveOrUpdateCopy()). This method will force Hibernate to copy any changes from other detached instances onto the instance you want to save, and thus merges all the changes in memory before the save.

    Session session = sessionFactory1.openSession();
    Transaction tx = session.beginTransaction();
    Item item = (Item) session.get(Item.class, new Long(1234));
    tx.commit();
    session.close(); // end of first session, item is detached
    
    item.getId(); // The database identity is "1234"
    item.setDescription("my new description");
    Session session2 = sessionFactory.openSession();
    Transaction tx2 = session2.beginTransaction();
    Item item2 = (Item) session2.get(Item.class, new Long(1234));
    Item item3 = session2.merge(item); // Success!
    tx2.commit();
    session2.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue where I have a player object that I'm trying to
I've got a pickem object that has one result. I'm having an issue getting
I have not clearly issue during query using two criterials like Id and Other.
I have an issue with an object I created and then use in a
I have the following issue: A java object contains two arrays of core datastore
I'm just starting with Object Oriented PHP and I have the following issue: I
I'm having an issue with an if statement I have an object called enemy2
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
I'm using Castle ActiveRecord in a warehouse project. I have several tables that get
i'm not so good at jquery and i've got this issue: i'm using jquery

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.