0 Replies Latest reply on Jan 19, 2008 4:33 AM by Thiagu Mariappan

    OneToOne relation gives problem

    Thiagu Mariappan Novice

      This is my TBL_PRODUCTS table structure is

      PRODUCT_ID pk
      PRODUCT_NAME
      CATEGORY_NAME
      SUBCATEGORY_NAME
      BRAND_NAME
      

      This is my TBL_CELLPHONE table structure is
      PRODUCT_ID pk
      BLUETOOTH
      CAMERA
      

      This is my TBL_CELLPHONE table structure is
      PRODUCT_ID pk
      NO_OF_CHANNELS
      WOOFERS
      

      my entity beans are
      @Entity
      @Table(name="TBL_PRODUCTS")
      public class TblProducts implements Serializable
      {
       @Id
       @Column(name="PRODUCT_ID")
       private BigDecimal productId;
      
       @Column(name="PRODUCT_NAME")
       private String productName;
      
       @Column(name="CATEGORY_NAME")
       private String categoryName;
      
       @Column(name="SUBCATEGORY_NAME")
       private String subcategoryName;
      
       @Column(name="BRAND_NAME")
       private String brandName;
      
       @OneToOne(fetch=FetchType.LAZY,mappedBy="tblProducts")
       private TblCellphone tblCellphone;
      
       @OneToOne(fetch=FetchType.LAZY,mappedBy="tblProducts")
       private TblTelevision tblTelevision;
      }
      ------------------------------------------------------------------------------
      @Entity
      @Table(name="TBL_CELLPHONE")
      public class TblCellphone implements Serializable
      {
       @Id
       @Column(name="PRODUCT_ID")
       private BigDecimal productId;
      
       private String bluetooth;
      
       private String camera;
      
       OneToOne(optional=false)
       @JoinColumn(name="PRODUCT_ID")
       private TblProducts tblProducts;
      }
      -----------------------------------------------------------------------
      @Entity
      @Table(name="TBL_TELEVISION")
      public class TblTelevision implements Serializable
      {
       @Id
       @Column(name="PRODUCT_ID")
       private BigDecimal productId;
      
       @Column(name="NO_OF_CHANNELS")
       private String noOfChannels;
      
       private String woofers;
      
       @OneToOne(optional=false)
       @JoinColumn(name="PRODUCT_ID")
       private TblProducts tblProducts;
      }
      

      TblProducts is my main table. I try to add OneToOne relation with other tables (TblTelevision and TblCellphone). I cant add more than one relation. If I add it gives incomplete deployment problem. If I remove any one of the OneToOne relation from TblProducts its works fine.
      Is there any mistake in my code
      Please help me

      By
      Thiagu.m