This discussion is archived
1 2 Previous Next 20 Replies Latest reply: May 23, 2013 1:45 AM by gimbal2 Go to original post RSS
  • 15. Re: How to refresh JPA data when the table data is updated from the backend
    943589 Newbie
    Currently Being Moderated
    Kayaman wrote:
    Did you try these options? http://stackoverflow.com/questions/2809275/disable-caching-in-jpa-eclipselink
    For the persistence cache setting I will depends on the IDE I trust the setting is correctly provided by JDeveloper.

    For the Query hint I haven't try, if rexamine my program and still no clue, I will spend some time to read further on the eclipselink document to implement the Query cache setting. I hope not to use this as I believe query hint are already too low level for programmer or designer to manage it.
  • 16. Re: How to refresh JPA data when the table data is updated from the backend
    r035198x Pro
    Currently Being Moderated
    leonyip wrote:

    The value is provided by the JDeveloper IDE, the setting should be right. Now I am skeptic about the EJB that cache the JPA object, but it shouldn't but nonetheless I am going to test it further.
    Don't let the IDE decide such important settings like that for you. Your application is very sensitive to caching so you need to be certain about the settings you put in and devote time to understanding them. Albeit as I said I seriously doubt that the IDE would suggest settings that cache data for over 2 days.You need more test cases to narrow down the source of the problem here.
  • 17. Re: How to refresh JPA data when the table data is updated from the backend
    943589 Newbie
    Currently Being Moderated
    leonyip wrote:
    r035198x wrote:
    leonyip wrote:
    So is there a EntityManager.refreshAll method or similar? At least I have the option to reload the data whenever I know there is an operation update from backend. This option can be executed by the operation
    No there is not one because all finds will hit the database anyway to get the right results if caching has been switched off.
    I agreed to this point. But some how my test result against it, I shall check further until I confirm this result. Thanks.
    I have tested and the no cache is working now. The actual setting is <property name="eclipselink.cache.type.default" value="NONE"/> instead of <property name="eclipselink.cache.type.default" value=""/>

    I have tried the EntityManager.refresh(entity) method, it will manually refetch the data from table even I set the JPA to cache, which is the feature that I want. But this method can only refresh one entity at a time. I need a method that I can refreshAll which I don't find in the current API. Anybody can reconfirm this?
  • 18. Re: How to refresh JPA data when the table data is updated from the backend
    r035198x Pro
    Currently Being Moderated
    leonyip wrote:
    I have tried the EntityManager.refresh(entity) method, it will manually refetch the data from table even I set the JPA to cache, which is the feature that I want. But this method can only refresh one entity at a time. I need a method that I can refreshAll which I don't find in the current API. Anybody can reconfirm this?
    There isn't such a method, it is not needed. EntityManager.refresh works on an Entity instance. You are expecting there to be a method that refreshes all instances of all entities. That is going to create unnecessary performance problems. Just refresh the instances that you are actually working with for your operation when you need to do it, not all entities.
  • 19. Re: How to refresh JPA data when the table data is updated from the backend
    1010571 Newbie
    Currently Being Moderated
    Hi,
    For me worked following code:

    EnityManager.getEntityManagerFactory().getCache().evictAll();

    --
    Jarek
  • 20. Re: How to refresh JPA data when the table data is updated from the backend
    gimbal2 Guru
    Currently Being Moderated
    1007568 wrote:
    Hi,
    For me worked following code:

    EnityManager.getEntityManagerFactory().getCache().evictAll();

    --
    Jarek
    1007568 wrote:Hi,
    For me worked following code:

    EnityManager.getEntityManagerFactory().getCache().evictAll();

    --
    Jarek
    Two assumptions in there.

    - that assumes JPA 2.0
    - that works on the second level cache which does not even have to be present

    If you actually read the thread, you'll find this is about refreshing a currently managed/attached entity, not a cache.
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points