【发布时间】:2021-06-05 11:02:32
【问题描述】:
我正在尝试将 ISIS 与 JDO 结合使用。我偶然发现了一个 Enums 问题,我可以在直接/简单的 java JDO 项目中重现该问题。
代码可以从
curl https://codeload.github.com/apache/isis-app-helloworld/zip/jdo | jar xv
我在 pom.xml 中添加了 lombok 依赖项:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</dependency>
我创建了一个类
package domainapp.modules.hello.dom.hwo;
import javax.jdo.annotations.IdentityType;
import lombok.AllArgsConstructor;
import lombok.Getter;
@javax.jdo.annotations.PersistenceCapable(identityType = IdentityType.DATASTORE, schema = "hello" )
@AllArgsConstructor
@Getter
public enum HelloWorldTypeEnum {
BIG,
SMALL;
}
并在 HelloWorldObject 中添加以下成员:
@Getter @Setter
@Extension(vendorName="datanucleus", key="enum-check-constraint", value="true")
private HelloWorldTypeEnum type = HelloWorldTypeEnum.BIG;
生成的 QHelloWorldObject 没有编译:
...
public QHelloWorldObject(PersistableExpression parent, String name, int depth)
{
super(parent, name);
if (depth > 0)
{
this.type = new EnumExpressionImpl(this, "type", depth-1);
}
else
{
this.type = null;
}
this.name = new StringExpressionImpl(this, "name");
this.notes = new StringExpressionImpl(this, "notes");
}
...
线
this.type = new EnumExpressionImpl(this, "type", depth-1);
有错误:
- The constructor EnumExpressionImpl(QHelloWorldObject, String, int) is undefined
- EnumExpressionImpl is a raw type. References to generic type EnumExpressionImpl<T> should be parameterized
我创建了干净的项目,剥离了所有 ISIS 的东西,并将其减少到只有 2 个 java 文件,并使用 OpenJDK 11 使用 Datanucleus 5.2.8 和 6.0.0-m1 进行了测试。结果总是一样的。
我在使用 OpenJDK 11 的 Opensuse 15.2 机器上。
根据https://www.datanucleus.org/products/accessplatform/jdo/mapping.html 支持枚举。
有人知道出了什么问题吗?
【问题讨论】:
-
我也使用 java 1.8 和 Datanucleus 5.2.8(maven 存储库中的某些东西是 5.2.9 或 5.2.7)完成了此操作,结果相同。
标签: java enums jdo datanucleus