When to use @Embedded and @Embeddable?

后端 未结 4 973
别跟我提以往
别跟我提以往 2021-01-18 01:10

Is it possible to annotate a class as @Embeddable or a property as @Embedded?

Sample code:

@Embeddable
class A{
...
}

cla         


        
4条回答
  •  清酒与你
    2021-01-18 01:54

    I guess if you annotate class as @Embeddable you don't need to annotate field as @Embedded. Also, if you annotate class as @Embeddable and you want to use it as primary key, you can use @Id only, but if it is not annotated as @Embeddable, you have to use @EmbeddedId on field to work as primary key.

提交回复
热议问题