1 Reply Latest reply on Nov 20, 2006 11:12 AM by Andrew Rubinger

    SequenceGenerator and the correct annotation syntax?

    Pieter-Jan Savat Newbie

      Hi,

      I finally got my entity beans working the way I want. But I found that to get the sequence working, I had to use the following annotations (look at the GeneratedValue annotation):

      @Entity
      @Table(name = "t_investigators",
       schema = "dryice"
      )
      @SequenceGenerator(name = "InvestigatorBeanSequence", sequenceName = "s_investigators")
      public class InvestigatorBean implements Investigator, Serializable {
      
       @Id
       @GeneratedValue(generator = "InvestigatorBeanSequence")
       @Column(name = "id")
       private long tableId;


      But according the JSR 220 specs (regarding persistence) the following should work (see example 1 chapter 9.1.9: GeneratedValue Annotation) but it doesn't:


      @Entity
      @Table(name = "t_investigators",
       schema = "dryice"
      )
      @SequenceGenerator(name = "InvestigatorBeanSequence", sequenceName = "s_investigators")
      public class InvestigatorBean implements Investigator, Serializable {
      
       @Id
       @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "InvestigatorBeanSequence")
       @Column(name = "id")
       private long tableId;


      I had to leave out the strategy to get things working. Is this normal?

      -- pj