I'm trying out ISIS in combination with JDO. I've stumbled upon an issue with Enums that I can reproduce on a direct/simple java JDO project.
The code can be gotten from
curl https://codeload.github.com/apache/isis-app-helloworld/zip/jdo | jar xv
I've added in the pom.xml the lombok dependency:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</dependency>
I create a class
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;
}
and added in the HelloWorldObject the following member:
@Getter @Setter
@Extension(vendorName="datanucleus", key="enum-check-constraint", value="true")
private HelloWorldTypeEnum type = HelloWorldTypeEnum.BIG;
The generated QHelloWorldObject does not compile:
...
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");
}
...
The line
this.type = new EnumExpressionImpl(this, "type", depth-1);
has the errors:
- The constructor EnumExpressionImpl(QHelloWorldObject, String, int) is undefined
- EnumExpressionImpl is a raw type. References to generic type EnumExpressionImpl<T> should be parameterized
I've created clean projects, stripping away all the ISIS stuff, and reducing it to only 2 java files, testing this with Datanucleus 5.2.8 and 6.0.0-m1 using OpenJDK 11. The result is always the same.
I'm on an Opensuse 15.2 machine with OpenJDK 11.
According to https://www.datanucleus.org/products/accessplatform/jdo/mapping.html Enums are supported.
Does anyone have a clue about what is going wrong?
It turned out to be as simple as this: don't make the enum Persistable.
Remove the line:
from the enum definition.