0 Replies Latest reply on Oct 31, 2007 11:39 AM by (Thomas_Spellman)

    LCDS w/ hibernate & mysql

      I've used hibernate tools to reverse engineer my DB tables into java objects + hibernate mapping files + tablenameHome DAO objects based on SessionFactory. I have this hosted in tomcat 5.5 in a linux vmware vm.

      For the sake of keeping it simple to start with, I disabled all but two tables in the hibernate.cfg.xml, and I removed their mapping associations with each other. When I do this, I'm able to successfully retrieve either table into a flex UI grid using Data Management Services. I have SQL debugging turned on in hibernate and I can see that the sql calls are just a simple select * on the one table.

      Here's the problem, when I add back in the many-to-many associations to the hibernate and data services files (and set them both to be lazy="true", and then I load either one of the tables into a grid, they do a bunch of sub selects into the associated tables and load all of the associations from the other table for each row. I had the understanding that this would only happen when one of those associations was actually used. I even tried setting lazy="extra" in the hibernate mappings to no avail.

      Is this only a problem with many-to-many, or is it something about how LCDS caches the associations, and so it always does follow the associations and loads them, even if it doesn' return this to the flex UI? I would like to have some way to selectively enable this. Sometime I just want to retrieve a simple list of objects without associations, and sometimes I want it to build the full object graph. Am I asking too much? Will I need to code custom retrieval queries into my java objects or DS config to accomplish this?