Incorrect code generation for record reference list

I have a Java service which take a record referece list as input parameter. When I use code generation, it generate IData for this parameter instead of IData. The sample is like this:

The input parameter is called Company which is a Record Reference List using a defined record named CompanyRec. ComapnyRec contains id and rating, both represented as String.

Here is the generated code:

// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();

// company
IData company = IDataUtil.getIData( pipelineCursor, “company” );
if ( company != null)
{
IDataCursor companyCursor = company.getCursor();
String company_1 = IDataUtil.getString companyCursor, “company” );
String rating = IDataUtil.getString( companyCursor, “rating” );
companyCursor.destroy();
}
pipelineCursor.destroy();

When I test, company is always null even though I have input values.

Then I modify the program as follows:

IData com = IDataUtil.getIDataArray( pipelineCursor, “comany” );
System.out.println("com is " + com);
if ( com != null)
{
for ( int i = 0; i < com.length; i++ )
{
IDataCursor comCursor = com[i].getCursor();
String company = IDataUtil.getString( comCursor, “company” );
String rating = IDataUtil.getString( comCursor, “rating” );
System.out.println("company is " + company + ", rating is " + rating);
comCursor.destroy();
}
}

Now it runs correctly.

I tried using Record List as input parameter, code generation does generate correct code like the above. Therefore, I think this seems to be a bug in code generation for Record Reference List type of parameter. Does anyone experience similar problem?

Yes, I ran into this just a couple days ago. Damned frustrating. No recourse except to rework the code as you did.

Anyone know why code generation gets a pipeline cursor for the input, destroys it, and then creates another cursor for doing the output? Is there some side-effect of getting a cursor that makes it unwise to hold on to one for the duration of the service?

Rob,

So I am not alone. Yes, it can be very incovenient if you have a couple of String Reference List as input parameters.

As far as the cursor create and destroy for input and output parameters. When I took the WM course before, I remember the instructor said it was okay to use the same cursor for output parameters without destroying it first. When you use code generation, it prompt you to choose “input” or/and “output” parameters. So I guess it just calls the same function twice if you choose both, and this function always put a destroy for the cursor.

Ah, that makes sense. It’s been a long time since I took the class so my brain apparently has purged that tidbit. Thanks for the info!