Sorry maybe but I don't understand but It seems that You state that one select for collection is not faster that subsequent calls for each member. It is absolutly not true !!!. Maybe it depends on database but e.g. Oracle usulally returns simplest query :(SELECT * from tab where id = ?) after 10-20 ms (even on local machine). It means that If You have collection of eg 200 entities You must execute 200 queries * 10 ms gives 2 sec. Returning it in one query usually takes much less time if optimizer takes correct path. In my project one query executes 30 ms , 60 subselects executes 0,5 sec. Many single selects has been major disadvantage of BMP Entity EJB. I had project in which change from BMP to CMP gave 10 times faster answer becouse CMP 2.0 can fetch many collection members in one select.
Onother problem is optimizer which sometimes can fail query, then I believe that IN(....) fetching aproach is rather better and more elastic (not each graph can be fetched via outer joins) IN(..) is used by JBoss CMP engine and OJB and works quite good. IN(...) Maybe I missed something, but i think that it is correct. From: <[EMAIL PROTECTED]> Re: Performance of "nested relations" 2003-02-19 00:00 Currently there is no way to grab contained collections in a single select (and I have extreme doubts that it would be a performance increase unless access to the database is over a slow network). A much better approach in most cases is to make the Map lazy. (For contained collections of _entities_, you can use a Hibernate query.) Philipp Meier <[EMAIL PROTECTED]> To: hibernate list <[EMAIL PROTECTED]> Sent by: cc: [EMAIL PROTECTED] Subject: [Hibernate] Performance of "nested relations" eforge.net 19/02/03 04:55 AM Hello, i have the following situation: Group -- 1:n --> Recipient, Recipient has a property of type java.util.Map Everything works fine, but loading the list of recipients is terribly slow because hibernate executes an sql query for each recipient to load the recipients's map. The logfiles look like the following: [..] Hibernate: SELECT recip0_.value as value, recip0_.field as field FROM recipient_values recip0_ WHERE recip0_.id=? Hibernate: SELECT recip0_.value as value, recip0_.field as field FROM Hibernate: SELECT recip0_.value as value, recip0_.field as field FROM recipient_values recip0_ WHERE recip0_.id=? recipient_values recip0_ WHERE recip0_.id=? [..] Is there a way that hibernate execute _one_ sql statement to load _all_ recipient_values for the recipients related to the Group? Or is there a better design over all? This are the mappings I currently use: -- Recipient <hibernate-mapping> <class name="Recipient"> <id name="id" type="long"> <generator class="native"/> </id> <map name="values" table="recipient_values"> <key column="id"/> <index column="field" type="java.lang.String"/> <element column="value" type="java.lang.String"/> </map> <many-to-one name="group" class="Group" column="group_" not-null ="true"/> </class> </hibernate-mapping> -- Group <hibernate-mapping> <class name="Group" table="Group_"> <id name="id" type="long"> <generator class="native"/> </id> <property name="name" type="java.lang.String"/> <set name="recipients" inverse="true" cascade="all" > <key column="group_"/> <one-to-many class="Recipient"/> </set> </class> </hibernate-mapping> Thanks, -billy. -- Meisterbohne Söflinger Straße 100 Tel: +49-731-399 499-0 eLösungen 89077 Ulm Fax: +49-731-399 499-9 ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel ********************************************************************** Any personal or sensitive information contained in this email and attachments must be handled in accordance with the Victorian Information Privacy Act 2000, the Health Records Act 2001 or the Privacy Act 1988 (Commonwealth), as applicable. This email, including all attachments, is confidential. If you are not the intended recipient, you must not disclose, distribute, copy or use the information contained in this email or attachments. Any confidentiality or privilege is not waived or lost because this email has been sent to you in error. If you have received it in error, please let us know by reply email, delete it from your system and destroy any copies. ********************************************************************** From -- Marek Mosiewicz <[EMAIL PROTECTED]> Jotel Bronisław i Marek Mosiewiczowie --------------r-e-k-l-a-m-a----------------- Tanie bilety lotnicze! http://samoloty.onet.pl ------------------------------------------------------- This SF.net email is sponsored by: SlickEdit Inc. Develop an edge. The most comprehensive and flexible code editor you can use. Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial. www.slickedit.com/sourceforge _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel