persistence@glassfish.java.net

RE: question on entity relation. - unidirectional

From: Gordon Yorke <gordon.yorke_at_oracle.com>
Date: Wed, 20 Feb 2008 11:00:28 -0500

With regard to the exception, have you added the attribute overrides to the Entities that share the Stockinforent?
--Gordon
  -----Original Message-----
  From: Eve Pokua [mailto:gorgeous65_at_msn.com]
  Sent: Wednesday, February 20, 2008 10:42 AM
  To: persistence_at_glassfish.dev.java.net
  Cc: ejb glassfish
  Subject: RE: question on entity relation. - unidirectional


  Hello,
   
  You are right and I've thought of that before. But all of my queries have a lot to
  do with Iteamdetailsent. And I have come so far with this project. Really, Stockinforent is actually part of Iteamdetailsent. I have divided it to give me a better control over the system. But may be
  I was wrong.
   
  eve






----------------------------------------------------------------------------
    Date: Wed, 20 Feb 2008 08:51:21 -0500
    From: gordon.yorke_at_oracle.com
    To: persistence_at_glassfish.dev.java.net
    CC: ejb_at_glassfish.dev.java.net
    Subject: Re: question on entity relation. - unidirectional

    Are you using Attribute overrides for the other class Suppliercompanyent?

    To solve your initial problem you could always query on the "Stockinforent" instead of "Iteamdetailsent" and use the OneToOne reference to display the "Iteamdetailsent" details.

    -- Gordon

    Eve Pokua wrote:

      Hello everyone,
       
      I tried to used embeddable class as below but then got some error:
       
      Descriptor Exceptions:
      ---------------------------------------------------------
      Exception [TOPLINK-93] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.DescriptorException
      Exception Description: The table [ITEMS] is not present in this descriptor.
      Descriptor: RelationalDescriptor(stockInformation.Suppliercompanyent --> [DatabaseTable(SUPPLIERS)])
      Runtime Exceptions:
      ---------------------------------------------------------
      Deployment error:
      The module has not been deployed.
      See the server log for details.


      The embeddable class is also in relation to another class. I'm kind of running out
      of ideas and would appreciate any suggestions. Unless I have to stick to bidirectional.
       
      Thanks
       
      eve


------------------------------------------------------------------------
        From: gorgeous65_at_msn.com
        To: ejb_at_glassfish.dev.java.net
        CC: persistence_at_glassfish.dev.java.net
        Date: Mon, 18 Feb 2008 15:36:15 +0000
        Subject: RE: question on entity relation. - unidirectional


        Hello everyone,
         
        I was doing a research on this and came across the following about embeddable class:
         
        http://www.theserverside.com/tt/articles/article.tss?l=MigratingJDBC
         
        Check the entity Accounts and ContactInformation:
         

@Entity
@Table(name = "ACT")
public class Account implements java.io.Serializable {

    protected String userId;
    protected ContactInformation info;
   
    public Account () {}
    
    public Account (String userId, ContactInformation info) {
        this.userId = userId;
        this.info = info;
    }

    @Id
    @Column(name="USERID")
    public String getUserId() {
        return userId;
    }
    @Embedded
    public ContactInformation getContactInformation() {
        return info;
    }
   
   
    
   ...
   ...

}_at_Embeddable
@Table(name = "ACT")

public class ContactInformation implements java.io.Serializable {

    protected String telephone;
    protected String email;
    protected String familyName;
    protected String givenName;
    
    public ContactInformation() {}

    public ContactInformation(String familyName,
                String givenName,
                String telephone,
                String email){

        this.givenName = givenName;
        this.familyName = familyName;
        this.email = email;
        this.telephone = telephone;
       }

    @Column(name="FIRSTNAME")
    public String getGivenName(){
        return givenName;
    }

   ...
   ...


}

        The above code was copied from:
         
        http://www.theserverside.com/tt/articles/article.tss?l=MigratingJDBC
         
        Could this be the answer to my problems. Instead, have two entities and then one table. Embedded
        one entity in another, so there is no worries of relations. Then in a case liken this, I would display data using
        a code as below:
         
        acount.contactInformation.telephone;
        acount.contactInformation.email;
        acount.contactInformation.familyName;
        acount.contactInformation.givenName;
         
        I'm I on the right track?
         
        Thanks
         
        eve
         


         


----------------------------------------------------------------------
          From: gorgeous65_at_msn.com
          To: ejb_at_glassfish.dev.java.net
          CC: persistence_at_glassfish.dev.java.net
          Date: Mon, 18 Feb 2008 13:16:11 +0000
          Subject: question on entity relation. - unidirectional

          hello everyone,
           
          I have two entities:
           
          public class Iteamdetailsent implements Serializable{
           
          @Id
           @Column(name="ITMID", nullable=false, length=8)
           private String itmid;
           
          ....
           
           
          And
           
          public class Stockinforent implements java.io.Serializable
          {
                  
                  @Id
                  @Column(name = "ITMID", insertable=false, updatable=false)
                  private String itmid;
           @OneToOne()
           @JoinColumn(name="ITMID")
                  private Iteamdetailsent iteamdetailsent;
           
          .....
           
          Stockinforent does not required an ID of it's own so it is using Iteamdetailsent foriegn key
          as it's id. Now I am also using the MVC to get and display data to client. Moreover, I am
          also using displaytag as part of my design. Now, I am using a servlet to retrieve data from the entities
          and then forwarding data to a JSP to display to client. For example, in my display JSP:
           
           
          <display:table name="sessionScope.iteamdetailsent" ..>
           <display:column property="itmid" title=" Itemcode "/>
                  <display:column property="itmname" sortable="true" headerClass="sortable" title=" Name "/>
           ...
          </display:table>
           
           
          Now, how do I display data or retrieve data of Stockinforent in relations to Iteamdetailsent?
          I am hoping that I won't have to use bi-directional entity relation, as it's so hard to maintain.
          Please, help.
           
           
          Thanks
           
          eve
           
           
           
           


----------------------------------------------------------------------
          Messenger on the move. Text MSN to 63463 now!


------------------------------------------------------------------------
        Think you know your TV, music and film? Try Search Charades!


--------------------------------------------------------------------------
      Think you know your TV, music and film? Try Search Charades!


------------------------------------------------------------------------------
  Messenger on the move. Text MSN to 63463 now!