Results 1 to 3 of 3

Thread: Entity refresh using spring data jpa module

  1. #1
    Join Date
    Aug 2008
    Location
    St Louis, MO
    Posts
    51

    Default 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. #2
    Join Date
    Apr 2006
    Location
    Dresden, Germany
    Posts
    483

    Default

    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

  3. #3
    Join Date
    Aug 2008
    Location
    St Louis, MO
    Posts
    51

    Default

    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?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •