cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Help on Query spec for subfolder

ED_11031300
3-Newcomer

Help on Query spec for subfolder

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 

ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

2 REPLIES 2

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!

Announcements

Top Tags