2 Replies Latest reply on Apr 9, 2006 1:17 AM by busitech

    Re: The pk value from TableGenerator(Again)

    Ritchie Koh Newbie

      Dear

      I was using TableGenerator as below

      @TableGenerator(name = "IdGen",
       table = "ID_GENERATOR",
       pkColumnName = "ID_NO",
       pkColumnValue = "1",
       valueColumnName = "NEXT_VALUE",
       allocationSize = 1)
      public class Board extends AbstractResultValue {
       ........
      }
      


      and the value of "NEXT_VALUE" column of "ID_GENERATOR" table is 1008.



      and Pk field has the annotation as below
       @Column(name = "BOARD_SEQ")
       @Id @GeneratedValue(strategy=GenerationType.TABLE, generator="IdGen")
       public Integer getBoardSeq() {
       return boardSeq;
       }
      


      and the value of "NEXT_VALUE" column of "ID_GENERATOR" table is 1008.

      I've expected that the value of the boardSeq field is 1008, but it has 2016.

      So there is the output message of debug mode of JBoss Application Server as below.

      15:49:59,203 DEBUG [SQL] select NEXT_VALUE from ID_GENERATOR where ID_NO = '1' for update
      15:49:59,531 DEBUG [AbstractBatcher] closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)
      15:49:59,609 DEBUG [Isolater] surrounding JTA transaction resumed [TransactionImpl:XidImpl[FormatId=257, GlobalId=RitchieKoh/14, BranchQual=, localId=14]]
      15:49:59,609 DEBUG [MultipleHiLoPerTableGenerator] new hi value: 1008
      15:49:59,609 DEBUG [AbstractSaveEventListener] generated identifier: 2016, using strategy: org.hibernate.id.MultipleHiLoPerTableGenerator

      At the above message, MultipleHiLoPerTableGenerator is getting the my expected value(1008),
      but finally the boardSeq field is inserted the 2016 value.

      I've thought that the boardSeq value is 1008 from "NEXT_VALUE" column of "ID_GENERATOR" table. but the boardSeq has 2016 finally.

      Why did get the 2016 value instead of 1008
      Please let me know why?

      # Ritchie