It's not a secret anymore!
The moose likes Object Relational Mapping and the fly likes Performance Tuning @ one-many tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Performance Tuning @ one-many tag" Watch "Performance Tuning @ one-many tag" New topic

Performance Tuning @ one-many tag

Mohammed Yousuff
Ranch Hand

Joined: Oct 17, 2007
Posts: 198
In my application i have two tables PRIMARY_TABLE, SECOND_TABLE.

PRIMARY_TABLE has a foreign key of SECOND_TABLE which has a one to many mapping.

For a single transaction it will have 15 child records, so for a single transaction i have to create 15 + 1 mapping objects in the memory. Is there any alternative approach available which will give all the child records for a single transaction in a single object itself.

Please let me know if have any clarification on what i discussed.

Here is the mapping file :

<class name="" table="SECOND_TABLE">
<id name="id" type="java.lang.Long" column="ID">
<generator class="sequence">
<param name="sequence">SECOND_TABLE_ID</param>
<property name="transationEventId" type="java.lang.Long" not-null="true" column="TRANSATIONEVENT_ID" insert="false" update="false"/>
<property name="key" type="java.lang.String" column="KEY" />
<property name="value" type="java.lang.String" column="VALUE" />

<class name="" table="PRIMARY_TABLE">
<id name="id" type="java.lang.Long" column="ID">
<generator class="sequence">
<param name="sequence">PRIMARY_TABLE_ID</param>
<property name="createDate" type="java.sql.Timestamp" column="TIMESTAMP" not-null="true"/>
<set name="txnDataElementSet" lazy="false">
<key column="TRANSATIONEVENT_ID"/>
<one-to-many class="" />

My Thoughts :
Try not to become a man of success but rather to become a man of value.
Reehan Lalkhanwar
Ranch Hand

Joined: Jun 16, 2007
Posts: 106
The Lazy Fetching or Automatic Collection Fetching of Hibernate ensures that the collection (Child records) are fetched only when they are used.
That should keep you from bothering about the number of collections as you may not use all the relations in a single situation.

Thank you,
I agree. Here's the link:
subject: Performance Tuning @ one-many tag
It's not a secret anymore!