CF9 EntityDelete: How to delete entities
coldfusion, coldfusion-9, hibernate
Solution
EntityLoad will return an array of the entity objects so we can loop over that and use entityDelete:
<cfloop array="#allUsers#" index="User">
<cfset entityDelete( User )>
</cfloop>
As ever when deleting data be careful! I generally prefer a soft delete.
Problem
If I have an array of entities, whats the easiest way of deleting the entire array of entities (or to put it this way, the entire ORM table)? I have: ``` <cfset allUsers = EntityLoad("User", {}, false)/> ``` Now to delete all the entities, would I use some sort of a loop? If so, how do I access individual entity primary keys within? I tried: ``` <cfset userTemp = EntityLoad("User", allUsers[i].User.userID, true) /> ``` but that didn't work...