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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:46:51+00:00 2026-06-15T21:46:51+00:00

Here is my configuration, first persistence.xml: <persistence xmlns=http://java.sun.com/xml/ns/persistence xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd version=2.0> <persistence-unit name=db

  • 0

Here is my configuration, first persistence.xml:

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0">     
<persistence-unit name="db" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <!-- This is needed to allow it to find entities by annotations -->
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <shared-cache-mode>ALL</shared-cache-mode> 

    <properties>
    <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
        <property name="javax.persistence.jdbc.user" value="user"/>
        <property name="javax.persistence.jdbc.password" value="password"/>
        <property name="javax.persistence.jdbc.url" value="jdbc:mysql://ip/dbname"/>

        <property name="eclipselink.logging.level" value="FINEST"/>     
        <property name="eclipselink.weaving" value="static"/>
        <property name="eclipselink.cache.type.default" value="SoftWeak"/>

    </properties>
</persistence-unit>
</persistence>

Here is how I create my EntityManagerFactory.

private static EntityManagerFactory factory = null;

public synchronized static DBStore getInstance() {
    if (factory == null) {
        factory = Persistence.createEntityManagerFactory("db");
    }
    return new DBStore(factory.createEntityManager());
}

where DBStore is the object which I use as a middle man to access the EntityManager.

Using EclipseLink 2.4

And here is the problem. If I create thread 1, get a DBStore object for it, make some changes to an existing entity, commit them to the database, and I have another concurrent thread (2) load that same entity before and after the change was made and committed, the second thread does not see the changes committed by the first thread. I know the changes are in the database because I can see them. Also if on the second thread I call EntityManager.refresh(entity) before checking the values of the the entity, then it works fine. So my guess here is that my two threads are not sharing their cache with each other even though EclipseLink is supposed to do that if you use the same EntityManagerFactory, which I am considering it is static.

So what is wrong with my setup?

  • 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-15T21:46:53+00:00Added an answer on June 15, 2026 at 9:46 pm

    Each EntityManager has its own cache as they are meant to represent separate transaction contexts. So pre existing entities read into an EntityManager will not show changes from others unless refreshed or the EM is cleared and the entity reread. Eclipselink caching with respect to JPA is described here: http://wiki.eclipse.org/EclipseLink/Examples/JPA/Caching

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

Sidebar

Related Questions

First of all, here's the full source code: http://pastebin.com/5teGNrPC *> IDENTIFICATION DIVISION. PROGRAM-ID. CAddress.
Here is the web.config; <?xml version=1.0 encoding=UTF-8?> <configuration> <system.web> <customErrors mode=Off> </customErrors> <authentication mode=Forms>
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
I've got three questions here. First, does pom.xml of maven have any difference from
I am using git configuration mentioned here If I create a new tab and
I have a simple unit test case (extensive question here ) on a configuration
I'm new to spring controllers using annotated controllers. Here is my configuration Bean definition
Here is my incomplete StructureMap configuration: PS: Big apologies for asking you to write
Here is my config file: # Doctrine Configuration doctrine: dbal: default_connection: flux connections: flux:
Here's a common, simple task: Read configuration settings from a configuration file, save the

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.