Highlighted
Absent Member.
Absent Member.
926 views

Unexpected Behavior in a returned List

Jump to solution

Hi,

I am using Managed COBOL on .NET and I fetch a list of customers from the Oracle Database and then add them to a list of type List[Customer]

the problem is at the debug everything is okay and the list is 100% filled with the right objects with the right values and when it's returned to be set to another list on the other also managed project - I've separated the business logic from the desktop view in two projects- the result is having the list filled with the object of the last entry of the list that was originally fetched for example if the list has the values 

1

2

3

4

the result of returning the list is 

4

4

4

4

and I repeat at debug time every thing is okay at the business logic project!!

could anyone please tell me what's going on ??

Best Regards

Tags (1)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.
Absent Member.

Dear Chris,

Tank you very much. I'd figured it, the problem was that I just change the attributes of an object at the local-storage section of the method so I keep changing the same object and adding it to the list which practically means that I just add a new reference to the same object to the list, so I just changed my code to add a new object with the newly fetched values dynamically and I wrote a constructor that takes the record as an argument so it now looks like:

write customers-list from new Entities.Customer(customer-record)

and as usual fro COBOL it just works!!

Kind Regards

View solution in original post

0 Likes
2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Can you please zip up your project and send to me at chris.glazier@microfocus.com so that I can review it?

Also include notes on where in the program the problem is occurring?

Thanks.

0 Likes
Highlighted
Absent Member.
Absent Member.

Dear Chris,

Tank you very much. I'd figured it, the problem was that I just change the attributes of an object at the local-storage section of the method so I keep changing the same object and adding it to the list which practically means that I just add a new reference to the same object to the list, so I just changed my code to add a new object with the newly fetched values dynamically and I wrote a constructor that takes the record as an argument so it now looks like:

write customers-list from new Entities.Customer(customer-record)

and as usual fro COBOL it just works!!

Kind Regards

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.