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. ********************************************************************** ------------------------------------------------------- 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