Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Hello, I'm trying to create my custom Enum with Java code, so I created a class
@GenAsEnumeratedType
public class LayerEnum extends _LayerEnum {
private static final long serialVersionUID = 1L;
public static final LayerEnum LAYER1 = toLayerEnum("Layer1");
public static final LayerEnum LAYER2 = toLayerEnum("Layer2");
}
Then I'm adding it as a property to my custom Part which is using it
@GenAsPersistable(superClass = WTPart.class, extendable = true,
properties={ @GeneratedProperty(name="layer", type=LayerEnum.class, initialValue = "LayerEnum.LAYER1") } ,
foreignKeys = {@GeneratedForeignKey(foreignKeyRole=@ForeignKeyRole(name="master", type=MyPartMaster.class))})
public class MyPart extends _MyPart {
static final long serialVersionUID = 1;
public static MyPart newMyPart() throws Exception {
final MyPart instance = new MyPart();
instance.initialize();
return instance;
}
}
The problem I encounter is that, when I try to create the new Part I get exception which is "Cannot initialize class LayerEnum".
Then I check that when I run the command ant -f bin/tools.xml sql_script .... my LayerEnum is not included in the sql_script. Is that normal when creating custom Enums like that? And what can be the reason for that my enum is not being included in the SQL script -> Not registered in the Database. In fact, when I check my custom Part in the database with desc MyPart I see the column of my LayerEnum
Yes, I'm trying to creating EnumeratedType Subclass.
Actually, the place from where I'm looking is this one - Modeling Business Objects (ptc.com)