gpt4 book ai didi

java - Eclipselink实体类自动扫描发现非实体

转载 作者:行者123 更新时间:2023-12-01 16:02:30 25 4
gpt4 key购买 nike

我已经激活了 Eclipselink 2.0 的自动检测模式来查找 @Entity 注解的类:

<exclude-unlisted-classes>false</exclude-unlisted-classes>

但是 Eclipselink 告诉我应该向我的实体添加一个 ID:

Caused by: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.ValidationException Exception Description: Entity class [class com.example.domain.Image] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.

示例类:

import java.util.HashSet;
import java.util.Set;

//@Entity No annotation!
public class Image extends File {

private int width;
private int height;
private Set<Image> variants = new HashSet<Image>();

}

如何告诉 Eclipselink 没有 @Entity 注释的类不是实体?

最佳答案

问题的根源是一个已编译的类,该类之前有一个 @Entity 注释。编译后的类文件仍然具有此注释,因此 Eclipselink 认为它是一个实体。运行maven clean后,一切都按预期工作。

关于java - Eclipselink实体类自动扫描发现非实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3462097/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com