Is the JPA @Embedded annotation mandatory?

后端 未结 2 1107
既然无缘
既然无缘 2021-01-08 01:07

I have tried omitting the @Embedded annotation and still the fields have been embedded in the table. I cannot find anything which would say tha

2条回答
  •  耶瑟儿~
    2021-01-08 01:52

    Embedded-Embeddable is not mandatory, but it gives you nice OOP perspective of your entities' relationship. Another way to do such a thing - is to use OneToOne mapping. But in such a case entity WILL be written to separate table (while in case of embedded it CAN be written to the separate table in your DB).

提交回复
热议问题