Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Eclipselink retrieves old data, but data is already updated in the database. Where does it get the old data from?

Dear Tom,

this seems to work. Great. Thanks!

Raven

On Fri, Apr 23, 2010 at 2:49 PM, Tom Ware <tom.ware@xxxxxxxxxx> wrote:
> EclipseLink has a 2nd level cache.  Is it possible the objects you are
> reading are already in that cache?
>
> Try adding the query hint, eclipselink.refresh=true to your query:
>
> q1.setHint(eclipselink.refresh, true);
>
> -Tom
>
> Raven McSmith wrote:
>>
>> Hi,
>>
>> in my project I have to Eclipse RCP plugins. Both are configured to
>> use Eclipselink on one and the same database. Both get the same
>> credentials.
>> If the first plugin, showing some views to add data to the database,
>> is started it shows the data from the database and the operation
>> directly write to the database and I can see, with an 3rd party
>> database manager tool, that the changes are saved in the database.
>>
>> Then from my menu the second plugin is called. It will just read the
>> data and then show and do some visualisation with it, it shows data
>> which is old. All new added or modified objects from my first plugin
>> are not shown. I have to quit the program and restart it, and then my
>> second plugin also sees the changes.
>>
>> Since the database connection for my second plugin is established
>> after the first plugin flushed all data and closed the transaction, ..
>>
>> ...why does my second plugin not see the changes?
>>
>> my code is more or less:
>>
>> ...
>> private List<A> aList = new ArrayList<A>();
>>
>> public void loadData() {
>>
>> dbDriver = get...
>> dbUrl = get...
>> dbUser = get...
>> dbPass = get...
>>
>> if (dbUrl.contains("derby:")) setLocalDatabase(true);
>>
>> Map properties = new HashMap();
>> properties.put("javax.persistence.jdbc.driver", dbDriver);
>> properties.put("javax.persistence.jdbc.url", dbUrl);
>> properties.put("javax.persistence.jdbc.user", dbUser);
>> properties.put("javax.persistence.jdbc.password", dbPass);
>> try {
>>        factory = Persistence.createEntityManagerFactory(
>>                PERSISTENCE_UNIT_NAME, properties);
>> } catch (Exception e) {
>>        System.out.println(e);
>> }
>> em = factory.createEntityManager();
>>
>> em.clear();
>>
>> Query q1 = em.createQuery("SELECT m FROM A m ORDER BY m.position, m.name
>> ASC");
>>
>> aList.clear();
>> aList.addAll(q.getResultList());
>>
>> }
>>
>> Can you help and tell my what I am doing wrong? Why doesnt the second
>> plugin see the changes?
>>
>> Thanks
>>
>> Raven
>> _______________________________________________
>> eclipselink-users mailing list
>> eclipselink-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>


Back to the top