This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Performance Tuning @ one-many tag

 
Mohammed Yousuff
Ranch Hand
Posts: 198
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Reehan Lalkhanwar
Ranch Hand
Posts: 106
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic