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

雨燕双飞 提交于 2019-12-03 11:11:14

问题


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?

回答1:


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.



来源:https://stackoverflow.com/questions/39643960/whats-the-difference-between-javax-persistence-id-and-org-springframework-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!