Member functions do not work on ORM object method results

Description

When trying to access results from an ORM object via a member function, ex: array.each(), I get this: No matching Method/Function for org.hibernate.collection.PersistentBag.each(lucee.runtime.type.Closure) found.

Consider this general example where a persistent user object can have many roles.

User.cfc

Role.cfc

This relationship will in turn create the function getRoles() in the user object which will return an array of role objects that I want to access.

The below code is what errors...
Note that this runs in ACF 11.

example.cfm

Environment

Windows 8.1 / nginx / Tomcat 8.0.23 / Lucee 4.5.1.022 (WAR)

Activity

Show:
Lucee Fer
July 28, 2015, 7:29 PM
Edited

I figured this behavior too, and was about to open a new ticket. If it can help, I attach a full test case (case1.zip) I worked on to understand the issue...
NB: the problem occurs only after the EntitySave() call.

T Lingard
October 21, 2015, 2:51 PM

This is happening with arrays from Postgres Array fields as well.

Type: Native Array (java.lang.String[])
No matching Method/Function for [[Ljava.lang.String;.each(lucee.runtime.type.Closure) found]]

As Brad mentioned, it has to be changed to ArrayImpl before using the array with member functions

Luis Majano
October 27, 2015, 12:56 PM

This is reproducible anywhere you return array of entities.

Michael Offner
July 19, 2017, 6:04 AM

Lucee 5 support to loop any List objects like this out of the bag, because "PersistentBag" is a list object this works now just fine.

Michael Offner
July 19, 2017, 4:24 PM

this is already fixed

Duplicate

Assignee

Michael Offner

Reporter

Tony Junkes

Priority

Major

Fix versions

None

Affects versions

Configure