简体   繁体   English

“嵌入式”属性类型不应为 @Embeddable class

[英]'Embedded' attribute type should not be @Embeddable class

I have an @Embeddable class:我有一个@Embeddable class:

@Data
@Embeddable
public class Address {
    private String region;

    private String city;

    private String district;

    private String street;

    private int house;

And I have another class where i'm trying to use it:我还有另一个 class 我正在尝试使用它:

@Getter
@Setter
@NoArgsConstructor
@Entity
@Table(name = "db_order")
public class Order {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @ManyToOne
    @JoinColumn(name = "user_customer_id")
    private User customer;

    @Embedded
    private Address address;

Error错误

But I can see an error 'Embedded' attribute type should not be 'Address'.但我可以看到一个错误“嵌入式”属性类型不应该是“地址”。 What can be a reason for it?这可能是什么原因?

Probably IntelliJ doesn't know that the embeddable is part of your persistence unit.可能 IntelliJ 不知道可嵌入对象是您的持久性单元的一部分。 Have you listed the class in your persistence.xml?您是否在persistence.xml 中列出了class?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM