Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • Thank you @njjnex. But when you use the JpaRepository interface and call the save method from the Service class, you see that internally Spring Data JPA check if the entity is new or not. In this way when an entity implements Spring's Persistable interface, it overrides two methods: 1. Boolean isNew() and 2. Long getId(). But it's not working. Commented Dec 28, 2014 at 17:48
  • 5
    As I said I am getting into Spring Data Jpa and previously used own custom dao layers. I did the way you mentioned as above by passing the entityManager in dao implementation. That works fine but my question is why it doesn't work in the context of Spring data Jpa. Commented Dec 28, 2014 at 17:53