aspose file tools*
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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Performance Tuning @ one-many tag" Watch "Performance Tuning @ one-many tag" New topic
Author

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="com.test.data.access.objects.XYZDataElementDAO" table="SECOND_TABLE">
<id name="id" type="java.lang.Long" column="ID">
<generator class="sequence">
<param name="sequence">SECOND_TABLE_ID</param>
</generator>
</id>
<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>


<class name="com.test.data.access.objects.XYZTxnListDAO" table="PRIMARY_TABLE">
<id name="id" type="java.lang.Long" column="ID">
<generator class="sequence">
<param name="sequence">PRIMARY_TABLE_ID</param>
</generator>
</id>
<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="com.test.data.access.objects.XYZDataElementDAO" />
</set>
</class>


My Thoughts : http://passion4java.blogspot.com
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,
Reehan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Performance Tuning @ one-many tag