Jorg Heymans wrote:

I took the form2bean.flow example that is under CForms Block Samples (link is called "Bean Binding") and enhanced Form2Bean.java with a bit of get/set logging. I changed the calling flowscript method (form2bean in binding_example.js) to add 4 Contacts instead of 1.

Findings:
- getContacts() is called 5 times upon loading
- when removing 3 elements and saving the form, getContacts() is called 7 times. setContacts() is called once for each removed element.
- at the end getContacts() is called another 3 times.


This is important to know when hooking up CForms to an O/R mapping. I am curious to know how other people have gotten around this when dealing with large repeaters.

Not to prevent you from tinkering with this code, but a side comment about "hooking up an O/R mapping". I don't think I'd be totally off mark if I were to say that any respectable O/R mapping will make sure that:


* Any obj.get() will pull information from database only once during the life of the transaction, and only in case lazy loading is used
* Any set() won't write anything to database at all till some kind of obj.commit() or service.store(obj) is called


Given these two points, it becomes less important how many times set/get is called. But it does not mean it should not be fixed :)


PS Never worked with OJB / hibernate yet; how do they operate in such situation? IIRC, JDO operates exactly as described above.


Vadim



Reply via email to