persistence@glassfish.java.net

Re: entity relation

From: Andrei Ilitchev <andrei.ilitchev_at_oracle.com>
Date: Mon, 23 Mar 2009 09:11:12 -0400

It's the same in TopLink Essentials.
  ----- Original Message -----
  From: Eve Pokua
  To: java persistglassfish glassfish
  Sent: Friday, March 20, 2009 11:55 PM
  Subject: RE: entity relation


  Andrei,
   
  Thank you. but i am yet to install Eclipselink.
   
  eve
   

------------------------------------------------------------------------------
  From: andrei.ilitchev_at_oracle.com
  To: persistence_at_glassfish.dev.java.net
  Date: Fri, 20 Mar 2009 10:15:56 -0400
  Subject: Re: entity relation


  In Eclipselink
      @GeneratedValue(strategy = GenerationType.AUTO)
  is equivalent to:
      @GeneratedValue(generator="SEQ_GEN")

  where "SEQ_GEN" generator by default is:
      @TableGenerator(name="SEQ_GEN", table="SEQUENCE", pkColumnName="SEQ_NAME", valueColumnName="SEQ_COUNT", pkColumnValue="SEQ_GEN")

  That works on all database platforms.

  Note that the user can re-define AUTO by specifying their customary SEQ_GEN generator, for instance:
      @SequenceGenerator(name="SEQ_GEN", sequenceName="MY_SEQ", allocationSize=10)

    ----- Original Message -----
    From: Axl Mattheus
    To: persistence_at_glassfish.dev.java.net
    Sent: Friday, March 20, 2009 12:22 AM
    Subject: Re: entity relation


    On the id generation:


    What database are you using? The 'AUTO' generation strategy should actually be called 'DIFFERENT_FOR_DIFFERENT_DATABASES' or 'SOMETIMES_DOESNT_WORK' would also be a good name...


    ax/


    2009/3/20 Eve Pokua <gorgeous65_at_msn.com>

      Hi,
       
      everyone,
       
       
      please read the following and let me know if I am on the right track.
       
      I've entities-
       
      Iteams
       
      Customer
       
      Order
       
      Orderline
       
      The Orderline breaks down the many-to many relationship for order and Iteams.
      Now, I do remember creating the tables before I normalised them, the system would
      create an extra table(which I did not specified) for Iteams and Order. So it would
      insert the id (s) of Iteams and Order everytime it was created.
       
      The Orderline has fields -
       
      orderid
      itemid
      cusid
      qauntity.
       
      If i move the fields back into Order and create the many-to-many relationship
      between Order and Iteams, then the system will many it for me. Is this the
      best way to manage an application like this or should I stick to my normalisation
      as mentioned above.
       
      Also, I would like the DB to generate the id fields automatically, so in my entities,
      I've specified as-
       
      @Entity
      @Table(name="ORDERS")
      public class Orderent implements Serializable {
          private static final long serialVersionUID = 1L;
          @Id
          @GeneratedValue(strategy = GenerationType.AUTO)
          private Long ordID;
       
       
      .....
       
       
      But the DB keeps asking for id when i enter new dada. Now, how do I manage a situation
      like this?
       
      I'd appreciate any suggestions. Thanks
       
      eve
       
       


--------------------------------------------------------------------------
      Windows Live Hotmail just got better. Find out more!




------------------------------------------------------------------------------
  Windows Live Hotmail just got better. Find out more!