Version: Windchill 11.2
Use Case: I would like to perform windchill query spec for the following statement
SELECT NAME FROM SUBFOLDER WHERE ida3containerreference=80556;
below is my code:
public class qeurytest { public static void showFolder() throws WTException {
QuerySpec qs=new QuerySpec();
qs.setAdvancedQueryEnabled(true);
int foldertable=qs.appendClassList(wt.folder.SubFolder.class, false); ClassAttribute ca1 = new
ClassAttribute(SubFolder.class,SubFolder.NAME);
qs.appendSelect(ca1, new int[] {foldertable}, true);
SearchCondition sc= new SearchCondition(SubFolder.class,SubFolder.CONTAINER_ID,SearchCondition.EQUAL,"80556");
qs.appendWhere(sc,new int[] {foldertable});
System.out.println("Printing the queryspec of class --> " + qs); }
Description:
I am facing an error : Attribute "containerReference.key.id" of class "java.lang.Long" is not of type "java.lang.String"
why is this error coming up and what would be the windchill queryspec for the statement.
Thank you
Solved! Go to Solution.
Hi @ED_11031300
It is common mistake in your definition
Do not use the String definition because the ID is in Long type.
So use there the number 80556 without "
new SearchCondition(SubFolder.class,SubFolder.CONTAINER_ID,SearchCondition.EQUAL,80556);
PetrH
Hi @ED_11031300
It is common mistake in your definition
Do not use the String definition because the ID is in Long type.
So use there the number 80556 without "
new SearchCondition(SubFolder.class,SubFolder.CONTAINER_ID,SearchCondition.EQUAL,80556);
PetrH
Hello @HelesicPetr
Thank you for replying I thought SubFolder.CONTAINER_ID was having the issue thanks for clarifying, However 80556 is integer I had to type cast it to long.
new SearchCondition(SubFolder.class,SubFolder.CONTAINER_ID,SearchCondition.EQUAL,(long)80556);
Thanks again!