Status/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): Alexandre Potvin Latreille / Alexandre Potvin Latreille (Alexandre Potvin Latreille)
Created: 06/25/2015
Components: ORM Support
Versions: 11.0
Failure Type:
Found In Build/Fixed In Build: CF11_Final /
Priority/Frequency: Normal / All users will encounter
Locale/System: ALL / Win 2008 Server R2 64 bit
Vote Count: 15
Related Bugs:
CF-4090267 - Similar to
Problem Description:
entityNew, entityLoad and entityLoadByPk cannot be used if entities have an init() function with required arguments
Steps to Reproduce:
1. Define a persistent component with an init function that has required arguments
2. Make sure that there is already an existing record in the database table to which your entity is mapped
3. Call entityLoad('SomeEntity')
Actual Result:
ColdFusion throws a coldfusion.runtime.MissingArgumentException
Expected Result:
The rehydrated entity instances are returned
Any Workarounds:
1. Create a Factory for every entity which will be responsible for enforcing the required arguments. The Factory will have to be in the same package of the entity since we will want to mark the init method as package protected to avoid allowing the creation of the entities using the new keyword.
Downside: Creating a Factory for every entity is a burden and the business logic for every entity will now have to be spread across at least 2 components when most of the time it would be unnecessary.
2. Set the initmethod component attribute of the entity to initNoArgs. Create an init method with required arguments to use as the business constructor and revert back to the old createObject('component', 'SomeEntity').init(...) syntax for creating entities.
Downside: One could easily forget to call the init method while this is much less probable when using the new keyword.
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 4012852
External Customer Info:
External Company:
External Customer Name: Alexandre
External Customer Email:
External Test Config: My Hardware and Environment details:
Attachments:
Comments: