Skip to main content
12-Amethyst
July 3, 2023
Question

Problem with generating Enum table into the database and Windchill not finding it

  • July 3, 2023
  • 1 reply
  • 961 views

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

 

1 reply

14-Alexandrite
July 3, 2023
12-Amethyst
July 3, 2023

Yes, I'm trying to creating  EnumeratedType  Subclass. 
Actually, the place from where I'm looking is this one - Modeling Business Objects (ptc.com)