-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Ensuring no performance-related issues are there
PostPosted: Fri Mar 14, 2008 5:21 am 
Newbie

Joined: Fri Dec 28, 2007 7:38 am
Posts: 16
Hi every one.

This is my Table structure...

Tbl_Products

Product_id (primary key)
Product_name
Subcategory_name

And

Tbl_Car

Product_id (primary key)
Fuel_Type
Horse_Power

And

Tbl_Tv

Product_id (primary key)
No_Of_Channels
Tv_Type

I need to provide a relationship between these tables. Hence I use the OneToOne relation between the product table and all other subcategory tables. Following is my table entity bean classes.
Code:
@Entity
@Table(name="TBL_PRODUCTS")
public class TblProducts implements Serializable
{
   @Id
   @Column(name="PRODUCT_ID")   
   private BigDecimal productId;

   @OneToOne(fetch=FetchType.LAZY,mappedBy="productId")
   private TblCar tblCar;

   @OneToOne(fetch=FetchType.LAZY,mappedBy="productId")
   private TblTv tbltv;
}

@Entity
@Table(name="TBL_TV")
public class TblTv implements Serializable
{
   @Id
   @Column(name="PRODUCT_ID", insertable=false, updatable=false)
   private BigDecimal productId2;

   @OneToOne(optional=false)
   @JoinColumn(name="PRODUCT_ID")
   private TblProducts productId;
}

@Table(name="TBL_CAR")
public class TblCar implements Serializable
{
   @Id
   @Column(name="PRODUCT_ID", insertable=false, updatable=false)
   private BigDecimal productId2;

   @OneToOne(optional=false)
   @JoinColumn(name="PRODUCT_ID")
   private TblProducts productId;
}

I am not sure if this relation is correct or wrong.

Assuming, I have to fetch the Tbl_products information along with Tbl_car. I execute the following query.

select * from Tbl_product where subcategory_name =’car’

The results flashed are as expected but the query is performed on other sub-category tables also like Tbl_tv as observed in my console. No results are however fetched from other sub-cateogory tables; however.

But I am apprehensive about this logic for any performance issues that might crop-up. The concern is more as we have 10 different subcategories related with the product table with 10,000 records in it.

by
Thiagu.m


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.