Serializing a complex object ORM Entity dealing with relational entities

In ColdFusion 9 I am serializing an ORM entity. When doing this, though, it's missing relational entities.

The serializeJSON() method ColdFusion uses to convert complex objects into JSON notation doesn’t seem to work correctly on ORM objects. Any object that had a property that was an array of other objects is not returned when using serializeJSON() on ORM objects!

Has anyone tackled this sort of issue before? How did you handle it?

Thanks.

Answers


Issue resolved! This is not a bug you have to set remotingFetch to true! By default it is set to false for properties with one-to-one, one-to-many, many-to-one, or many-to-many relationships.


I've run into similar issues with remote methods and came up with a recursive function that will introspect your CFC and send back the properties you need. You can specify (with attributes on the CFC) which properties you do and don't want to return. Actually, you can do it by "groups" of properties, so you could assign "id" and "name" to the "compact" group and the rest of the properties in your CFC to the "full" group. It will also handle serializing nested components (ORM or otherwise). The other big advantage is that Adobe's serialization methods do not serialize properties from inherited objects. So if you have a parent object, you will not get those properties back when serialized. My toSerializable() method solves that.

Check it out: http://www.justcodefaster.com/blog/2012/07/toserializable-method-for-coldfusion-objects/


Need Your Help

bash: ./comp.out: Permission denied

c linux gcc permissions

I am trying to write a program that compares 2 files and returns if they are equal or not.

iPhone Automatic Device Provisioning Error

iphone

In my xcode organizer, I click "refresh" on the "Automatic Device Provisioning" and I keep getting this message: