I am not sure what the best way of mapping it would be so as to eliminate the circular reference.
I am not great at Hibernate. Maybe if you eliminated the one-to-many relationships on Film and Actor. Then you would have a separate collection of FilmActors that you could query by film or actor. It would eliminate the circular reference but I am not sure it's the best solution or what you had in mind. Let me know what you end up doing, I am curious. --Kelly _____ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Douglas McCarroll Sent: Sunday, November 26, 2006 7:53 AM To: [email protected] Subject: Re: [flexcoders] How to implement Lazy Hibernate? Hi Kelly, > Lazy Loading probably isn't going to help you. > > You probably want to consider doing an intermediate > class between any many-to-many associations in > hibernate so you have two many-to-one associations > instead. Thanks for your response Kelly, but I think that I already have an intermediate class, implemented on both client (.as) and server (.java) The FilmActor table has many-to-one relationships with both Film & Actor tables. FilmActor.java & FilmActorVO.as are the intermediate classes that map to this table. I'm guessing that you got the impression that I have no intermediate class from my explanation, right below the first link, which I oversimplified. Here's a revised version: Hi All, I'm attempting to create a Cairngorm/FDMS/Hibernate/MySQL example program which I'll publish to the community once completed. I used the MySQL Sakila sample DB (pared down to 3 tables - Film, Actor & FilmActor - at present) and used HibernateTools to reverse engineer the requisite Java and Hibernate files. So far, so good. I've even managed to successfully write corresponding .as files and implement the beginnings of a Cairngorm front end. And it works. Kind of. The problem is that the persistence layer takes forever to load, even though the 3 tables only have hundreds or thousands of records each. I've temporarily pared them down considerably (to 100, 100 & 500 records) and the program now loads quickly enough that I can continue development work, but the performance issue needs to be addressed. It's fairly easy to see what the problem is. Here's a picture of the variable window that depicts the situation in all its glory: http://www.brightwo <http://www.brightworks.com/technology/tech_questions/hibernate_lazy_associa tions/deeply_nested_actors_and_films.jpg> rks.com/technology/tech_questions/hibernate_lazy_associations/deeply_nested_ actors_and_films.jpg Beautiful, isn't it?? :-) There's a reference chain that goes like this on the client side: ActorVO references... A FilmActors ArrayCollection which contains... ObjectProxy instances (translations of FilmActor.java) which reference... Both ActorVO & FilmVO instances which both reference... A FilmActors ArrayCollection which contains... ObjectProxy instances (translations of FilmActor.java) which reference... Both ActorVO & FilmVO instances which both reference... Etc, etc, etc, etc, etc..... I wonder how many levels deep this goes? The program doesn't hang so I assume that Flex puts a stop to it at some point... Anyway, I'm assuming that the solution is to implement lazy associations. My understanding is that Hibernate does lazy associations by default, so once I set up my destinations properly all will be well. But despite several attempts, I keep getting error messages. Could one of the Hibernate gurus that inhabits this list point me in the correct direction? The DB's schema is outlined here: http://www.brightwo <http://www.brightworks.com/technology/tech_questions/hibernate_lazy_associa tions/index.html> rks.com/technology/tech_questions/hibernate_lazy_associations/index.html And all relevant code, plus my latest error message, is here: http://www.brightwo <http://www.brightworks.com/technology/tech_questions/hibernate_lazy_associa tions/code.txt> rks.com/technology/tech_questions/hibernate_lazy_associations/code.txt I assume that my problem is in data-management-config.xml, but I'm new to all of this and could be doing other things wrong as well. TIA! Douglas ------------------------------------------------- Douglas McCarroll CairngormDocs.org Webmaster http://www.Cairngor <http://www.CairngormDocs.org> mDocs.org Flex Developer http://www.brightwo <http://www.brightworks.com> rks.com 617.459.3840 -------------------------------------------------

