Duplicate
Details
Assignee
Michael OffnerMichael OffnerReporter
Tony JunkesTony JunkesPriority
MajorLabels
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Affects versions
Details
Details
Assignee
Michael Offner
Michael OffnerReporter
Tony Junkes
Tony JunkesPriority
Labels
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Affects versions
Created 8 July 2015 at 22:48
Updated 19 July 2017 at 16:24
Resolved 19 July 2017 at 16:24
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
component persistent="true" table="users" output="false" { property name="userId" fieldtype="id" ormtype="int" generator="native"; property name="name" ormtype="string" default=""; property name="roles" singularname="role" cfc="Role" fieldType="many-to-many" linkTable="user_roles" fkcolumn="roleId" inverseJoinColumn="userId"; public User function init() { return this; } }
Role.cfc
component displayname="Role" persistent="true" table="roles" output="false" { property name="roleId" fieldtype="id" ormtype="int" setter="false" generator="native"; property name="title" ormtype="string" default=""; property name="users" singularname="user" cfc="User" fieldType="many-to-many" linkTable="user_roles" fkcolumn="userId" inverseJoinColumn="roleId"; public Role function init() { return this; } }
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
user = entityLoadByPK("User", 1); list = ""; user.getRoles().each(function(role) { list = listAppend(list, role.getTitle()); }); writeOutput(list);