cancel
Showing results for 
Search instead for 
Did you mean: 

Searching header and item objects from one createQuery

Former Member
0 Kudos

Hi,

I'm getting NullpointException errors when attempting to run a query search from the header and item tables combined. Is it possible to do this?

SmartSyncJQueryFactory jquery = SmartSyncRuntime.getInstance().getJQueryFactory();

//get field names then implement their attributes.

JQueryAttribute[] jattrHeader = dmod.getHeaderAttributes();

JQueryAttribute[] jattrItem = dmod.getItemAttributes();

int i;

for( i = 0; i < jattr.length; i++ )

{

compJattr<i> = jattr<i>;

}

for(int x=0; x < jattr2.length; x++)

{

i++;

compJattr<i> = jattr2[x];

System.out.println("Appending jattr2: " + i + ":" + compJattr<i>);

if(i == 38)

break;

}

JQueryCondition compcond = jquery.createCondition( new JQueryCondition[] { jcond1Header, jcond2Item },

LogicalOperatorType.OR);

JQuery query = jquery.createQuery(compJattr, compcond , jsort);

if(query!=null)

{

queryResult = dataFacade.executeQuery(query);

iteratorSyncBos = queryResult.iterator();

System.out.println("@@@@@@Query is successful....");

}

The null point exception occurs here:

JQuery query = jquery.createQuery(compJattr, compcond , jsort);

Thanks,

Chiedu

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Chiedu,

Are you sure that all the three (compJattr, compcond , jsort) attributes are not null before executing the below statement..

JQuery query = jquery.createQuery(compJattr, compcond , jsort);

Cheers,

Karthick

Former Member
0 Kudos

Hi Karthick,

Thanks for the feedback. I checked all attributes prior to passing them to createQuery() method by viewing the stored data.

If i remove all attributes for the Item, item attribute and item condition. the function works. Is there a rule against combining header and item attributes together to perform a query?

Thanks,

Chiedu

Answers (2)

Answers (2)

Former Member
0 Kudos

I discovered one of my params to be null.

Thanks,

Chiedu

Former Member
0 Kudos

Hi Chiedu,

Its nice to know that the problem is resolved.

Kindly award the appropriate points and then close the Question.

<<<Are you sure that all the three (compJattr, compcond , jsort) attributes are not null before executing the below statement..

JQuery query = jquery.createQuery(compJattr, compcond , jsort);>>>>

Cheers,

Karthick

Former Member
0 Kudos

hello chiedu,

from your codes, though you did not post the line which initializes the compJattr

array, there's a high possibility that some elements of this array are null. be sure

that all elements are not null before passing it to <i>query.createQuery</i> method.

regards

jo