1 Reply Latest reply: Apr 19, 2012 10:31 AM by cdelahun RSS

    Knowing the Primary Key Sequence Generator of a table

    758746
      Hello All,

      I'm working on an application that uses Oracle toplinks/JPA for persistence. The entity classes in the application have primary key fields with annotations @Id and @GeneratedValue(strategy = GenerationType.AUTO). Per our understanding, this means the primary key generation is done by JPA/Top-links. When we see our database, we notice only one SEQUENCE table available and that table has only one row, while in the application, we are getting different sequence numbers for the primary key of each entity. So, not clear on how this sequence number is generated. Could anybody share information on where the sequence number is stored for each entity/table? Really appreciate your help here. Our database is MSSQL.

      Thank you,
      Venkatesh
        • 1. Re: Knowing the Primary Key Sequence Generator of a table
          cdelahun
          EclipseLink/TopLink uses Table sequencing for GenerationType.AUTO because it is more portable between databases. My understanding of your issue is from
          http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#Table_sequencing
          Each row in the table represents one sequence generator, and your entities are all using the same default sequence generator and so all use the same row.

          To use multiple rows I believe you need to define multiple TableGenerators.

          Best Regards,
          Chris