Announcement Announcement Module
Collapse
No announcement yet.
Entity refresh using spring data jpa module Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Entity refresh using spring data jpa module

    How to force an entity to refresh in the same session as it is saved so that child entities that are mostly reference data type can be lazy loaded. I think in the traditional jpa route we could probably do something like this:
    Code:
     entityManager.refresh(entity);
    How do we achieve this with a repository implementation of the spring data jpa module?

  • #2
    Just add the custom implementation method as described in [0]. In your implementation class just refer to the EntityManager via @PersistenceContext. If you think this should be inside JpaRepository, feel free to open a ticket in our JIRA.

    [0] http://static.springsource.org/sprin...mplementations

    Comment


    • #3
      The reason I was wanting to do this was when I persist a new entity that has references to detached associations (reference data type) the only way to get those attached again was to do a cascading refresh. My question is would it make sense for the framework to go ahead & do the refresh right after persist so that the entity returned back has all the associations refreshed down the chain?

      Comment

      Working...
      X