-->
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: Problem while saving data in child table
PostPosted: Fri Aug 05, 2011 5:44 pm 
Newbie

Joined: Sun Nov 19, 2006 6:55 pm
Posts: 9
Hi All,

I have a parent child relation ship in my db and I am trying to save data.Data gets properly saved into parent table but it does not get saved into child table.

I have defined OneToMany relation in parent table and ManyToOne in child table.All of import statements are importing javax.persistence classes (can that be an issue?).

Another thing is that child class is child of two classes(It has two columns that have ManyToOne relations).Is that an issue?

Parent class :-

Code:
@Entity
@Table(name = "CSO_PROFILE")
@XmlRootElement
public class CsoProfile implements Serializable {

        private int csoProfileId;
   private String csoProfileName;
   private String defaultProfile;
   private String langPair;
   private int transEngineProfileMapId;
   private String customerName;

private List<CustomerCsoProfileMap> customerCsoProfileMapList;

@OneToMany(cascade = CascadeType.ALL, mappedBy = "csoProfileId")
   public List<CustomerCsoProfileMap> getCustomerCsoProfileMapList() {
        return customerCsoProfileMapList;
    }

    public void setCustomerCsoProfileMapList(List<CustomerCsoProfileMap> customerCsoProfileMapList) {
       this.customerCsoProfileMapList = customerCsoProfileMapList;
    }

Child class -
Code:
@Entity
@Table(name = "CUSTOMER_CSO_PROFILE_MAP")
@XmlRootElement
public class CustomerCsoProfileMap {
   
   private int customerCsoProfilemapId;
   private Customer customerID;
    private CsoProfile csoProfileId;
   
    @SequenceGenerator(name = "CustCsoProfile_Gen", sequenceName = "customer_cpm_sequence")
    @Id
    @GeneratedValue(generator = "CustCsoProfile_Gen")
    @Basic(optional = false)
   @Column(name = "CUSTOMER_CSO_PROFILE_MAP_ID")
   public int getCustomerCsoProfilemapId() {
      return customerCsoProfilemapId;
   }
   public void setCustomerCsoProfilemapId(int customerCsoProfilemapId) {
      this.customerCsoProfilemapId = customerCsoProfilemapId;
   }
   
   
   @JoinColumn(name = "CUSTOMER_ID", referencedColumnName = "CUSTOMER_ID")
   @ManyToOne(optional = false)
   public Customer getCustomerID() {
      return customerID;
   }
   public void setCustomerID(Customer customerId) {
      this.customerID = customerId;
   }
   
   
   
   @JoinColumn(name = "CSO_PROFILE_ID", referencedColumnName = "CSO_PROFILE_ID")
    @ManyToOne(optional = false)
    public CsoProfile getCsoProfileId() {
           return csoProfileId;
       }

       public void setCsoProfileId(CsoProfile csoProfileId) {
           this.csoProfileId = csoProfileId;
       }

   }


Data should be saved in CustomerCsoProfileMap when data is inserted in CsoProfile.There is no error in logs.
What am I doing wrong?


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.