티스토리 뷰

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

 

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. If Spring has created that annotation only for support the JPA annotation,

stackoverflow.com

 

mongodb와 mysql을 왔다갔다하면서 entity를 만들던 도중

mysql에서 사용하던 id를 통해서 mongodb에서 id를 지정했는데, mongodb의 default id인 objectId를 통해서 데이터가 생성되는 것을 확인할 수 있었다.

 

그렇다면 id annotation이 정상적으로 동작하지 않는다고 보여졌다.

 

javax.persistence.Id는 JPA에 의해서 정의된 annotation이고, rdbms의 기준으로만 적용이 된다고 한다.

 

org.springframework.data.annotation.Id는 non-releation database (ex)nosql)이거나 공통 persistence API를 가지지 않은 프레임워크를 사용할때 쓴다고 한다. 대표적으로 mongodb나 solr 등을 말하는 것으로 보여진다.

 

'spring' 카테고리의 다른 글

[spring boot] requestParam object list or complicated object  (0) 2018.10.09
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함