0 Replies Latest reply on Apr 26, 2007 3:37 PM by Abhinav Nigam

    Persisiting Related Objects with CMP

    Abhinav Nigam Newbie

      Your help is needed with entity beans when cascading the persist operation for related objects.

      There are two entities User & UserDetails related in one to one fashion. When I deploy the entity beans it adds an extra column as USERDETAIL RAW(255) in the DB. The DB is Oracle 10g XE. since th size of the usedetail object is more than 255 it does not insert the object. When I increased the size of the column to a large value it does not insert the record in the userdetail table.

      Is there any setting in Jboss? I have just added the extra jars for EJB3 support. The application deploys cleanly.

      I generated the entities using the net beans. The same problem persists.

      Abhinav

      The user entity is as follows...

      package org.integral.ats.vertebrae.ejb.user;
      
      import java.io.Serializable;
      import java.util.Date;
      
      import javax.persistence.CascadeType;
      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.GeneratedValue;
      import javax.persistence.Id;
      import javax.persistence.OneToOne;
      import javax.persistence.PersistenceProperty;
      import javax.persistence.PrimaryKeyJoinColumn;
      import javax.persistence.Table;
      import javax.persistence.Temporal;
      import javax.persistence.TemporalType;
      
      @Entity
      @Table(name="tusr")
      public class User implements Serializable
      {
      
       private static final long serialVersionUID = 1L;
      
       @Id
       @GeneratedValue
       @Column(name="USR_ID")
       private long userID;
      
       @Column(name="USR_LGN_ID")
       private String userLoginID;
      
       @Column(name="USR_ROLE_ID")
       private String userRoleID;
      
       @Column(name="LST_LGN_TS" )
       @Temporal(value = TemporalType.DATE)
       private Date lastLoginDate;
      
       @Column(name="USR_ADD_INF" )
       private String userAddInfo;
      
       @Column(name="CRTD_TS")
       @Temporal(value = TemporalType.DATE)
       private Date creationDate;
      
       @Column(name="CRTD_USR")
       private long createdByUser;
      
       @Column(name="UPDT_TS" )
       @Temporal(value = TemporalType.DATE)
       private Date updatedDate;
      
       @Column(name="UPDT_USR")
       private long updatedByUser;
      
       @OneToOne(cascade={CascadeType.ALL})
       @PrimaryKeyJoinColumn
       private UserDetail userDetail;
      
       public static long getSerialVersionUID() {
       return serialVersionUID;
       }
      
       public UserDetail getUserDetail()
       {
       return userDetail;
       }
      
       public void setUserDetail(UserDetail userDetail)
       {
       this.userDetail = userDetail;
       }
      
      // getters & setters for other fields
      }
      



      The UserDetail is as follows

      package org.integral.ats.vertebrae.ejb.user;
      
      import java.io.Serializable;
      import java.util.Date;
      
      import javax.persistence.Basic;
      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.GeneratedValue;
      import javax.persistence.Id;
      import javax.persistence.Table;
      
      @Entity
      @Table(name="tusrdtl")
      public class UserDetail implements Serializable
      {
      
       private static final long serialVersionUID = 1L;
      
       @Id
       @GeneratedValue
       @Column(name="USR_ID")
       private long userID;
      
       @Column(name="USR_FST_NM")
       private String firstName;
      
       @Column(name="USR_MDL_NM")
       private String middleName;
      
       @Column(name="USR_LST_NM")
       private String lastName;
      
       @Column(name="USR_DOB")
       private Date dateOfBirth;
      
       @Column(name="USR_PWD" )
       private String password;
      
       @Column(name="USR_LST_PWD_CHNG_TS")
       private Date lastPasswordChangeDate;
      
       @Column(name="USR_PWD_CHNG_FREQ")
       private int passwordChangeFreq;
      
       @Basic
       @Column(name="CRTD_TS")
       private Date creationDate;
      
       @Basic
       @Column(name="CRTD_USR")
       private long createdByUser;
      
       @Column(name="UPDT_TS")
       private Date updatedDate;
      
       @Column(name="UPDT_USR")
       private long updatedByUser;
      
      
       public static long getSerialVersionUID() {
       return serialVersionUID;
       }
      
       public long getCreatedByUser() {
       return createdByUser;
       }
       public void setCreatedByUser(long createdByUser) {
       this.createdByUser = createdByUser;
       }
      
       // getter & setter for other properties
      }