What's the difference between javax.persistence.Id and org.springframework.data.annotation.Id?

I'd be interested whether there is the difference between javax.persistence.Id and org.springframework.data.annotation.Id.

  1. If Spring has created that annotation only for support the JPA annotation, then why?
  2. Does org.springframework.data.annotation.Id have another [additional] purpose?
0

1 Answer

org.springframework.data.annotation.Id is currently used by Spring to support mapping for other non relational persistence databases or frameworks that do not have a defined common persistence API like JPA. So, it is normally used when dealing with other spring-data projects such as spring-data-mongodb, spring-data-solr, etc.

javax.persistence.Id is the annotation defined by JPA for all its implementations. Have in mind JPA only applies for management of relational data.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like