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


Reply via email to