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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:33:11+00:00 2026-05-20T14:33:11+00:00

My current project uses HSQLDB2.0 and JPA2.0 . The scenario is: I query DB

  • 0

My current project uses HSQLDB2.0 and JPA2.0 .

The scenario is: I query DB to get list of contactDetails of person. I delete single contactInfo at UI but do not save that data (Cancel the saving part).

I again do the same query, now the result list is 1 lesser than previous result coz I have deleted one contactInfo at UI. But that contactInfo is still available at DB if I cross check.

But if I include entityManager.clear() before start of the query, I get correct results every time.

I dont understand this behaviour. Could anyone make it clear for me?

  • 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-20T14:33:12+00:00Added an answer on May 20, 2026 at 2:33 pm

    Rather than querying again, try this:

    entityManager.refresh(person);
    

    A more complete example:

    EntityManagerFactory factory = Persistence.createEntityManagerFactory("...");
    EntityManager em = factory.createEntityManager();
    em.getTransaction().begin();
    
    Person p = (Person) em.find(Person.class, 1);
    assertEquals(10, p.getContactDetails().size()); // let's pretend p has 10 contact details
    p.getContactDetails().remove(0);
    assertEquals(9, p.getContactDetails().size());
    
    Person p2 = (Person) em.find(Person.class, 1);
    assertTrue(p == p2); // We're in the same persistence context so p == p2
    assertEquals(9, p.getContactDetails().size());
    
    // In order to reload the actual patients from the database, refresh the entity
    em.refresh(p);
    assertTrue(p == p2);
    assertEquals(10, p.getContactDetails().size());
    assertEquals(10, p2.getContactDetails().size());
    
    em.getTransaction().commit();
    em.close();
    factory.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My current project uses some ListFragments to show rows of data. The rows get
On my current project, which is a delivery system, I have a list of
In my current project, I want to convert List<String> to RegionLabel Object. For instance,
My team current uses a Sharepoint list to manage bugs, issues etc for the
This current project I've been assigned uses the Version 3.1 levels of: Microsoft.Practices.EnterpriseLibrary.Common; Microsoft.Practices.EnterpriseLibrary.Data;
My current project is in rails 2.3.5 which uses restful authentication. I am moving
The context : My current project uses VistaDB as it really fits the main
My current project uses JPA and HSQLDB. I would like to persist multiple related
On my current project I've noticed that IE uses a quite a lot of
My current Xcode project uses some files that I originally created in another Xcode

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.