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.

 

 

 

--Kelly

 

 

 

 

  _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Douglas McCarroll
Sent: Saturday, November 25, 2006 3:32 PM
To: [email protected]
Subject: [flexcoders] How to implement Lazy Hibernate?

 

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?? :-)

In other words, every actor references all films that the actor is in...

And each of these films references all actors in the film...

And each of these actors references all films that the actor is in...

And each of these films references all actors in the film...

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

-------------------------------------------------

 

Reply via email to