Ivan McAvinchey
unread,Nov 15, 2016, 1:39:34 PM11/15/16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to cf-orm-dev
I have two entities in a one-to-many relationship, Staff and StaffDepartment.
In Staff.cfc:
property name="department" fieldtype="many-to-one"
cfc="StaffDepartment" fkcolumn="departmentid"
insert="false" update="false" orderby="position asc";
In StaffDepartment.cfc:
property name="position" ormtype="int";
What I want is to return staff, ordered by department position. So I try:
rc.staff = entityLoad("Staff", {isactive = 1}, "department asc");
However this gives me the staff sorted by the primary key of StaffDepartment.
My question is whether this is possible using just EntityLoad()? I was hopeful that specifying orderby on department would do it but that only seems to apply if I was running getDepartment() on Staff (which would only in this case return one record anyway, so not applicable, would be the other way around).
Note I can do this fine using ORMExecuteQuery and HQL, my question is just is there a way to do this using EntityLoad() specifically!
rc.staff = ORMExecuteQuery("from Staff s
join fetch s.department d
where s.isactive = 1
order by d.position asc, s.position asc");