4 Replies Latest reply on Feb 23, 2006 9:46 AM by instinct

    Schemaupdate tries to create existing sequences ?

    barc

      Hi,

      I use an entity bean looking like this

      @Entity
      @Table(name="t_gridcells", schema="grid")
      @SequenceGenerator(name="GridCellBeanSequence", sequenceName="grid.s_gridcells")
      public class GridCellBean {
      
       private Integer id;
      
       @Id(generate=GeneratorType.SEQUENCE, generator="GridCellBeanSequence")
       public Integer getId() {
       return id;
       }
      
       public void setId(Integer id) {
       this.id = id;
       }
      
      }
      
      


      This works. The sequence s_gridcells in my grid schema is used to generate the id for new beans.
      The only problem is that when I deploy my ear-file the JBoss server gives the following error-output:

      -------------------------------------------------------
      09:31:23,093 INFO [DatabaseMetadata] table not found: grid.s_gridcells

      09:31:23,203 ERROR [SchemaUpdate] Unsuccessful: create sequence grid.s_gridcells
      09:31:23,203 ERROR [SchemaUpdate] ERROR: relation "s_gridcells" already exists
      -------------------------------------------------------

      Does anyone have a clue how to fix this?

      I know that if I change the sequenceName="grid.s_gridcells" to sequenceName="s_gridcells" the sequence isn't used/found. So, because there is no "schema" attribute in the SequenceGenerator-annotation I put the "grid." in front of the name.

      Any help is extremely welcome....

      cheers,
      pj

        • 1. Re: Schemaupdate tries to create existing sequences ?
          barc


          If someone from JBoss could help me out in this....

          • 2. Re: Schemaupdate tries to create existing sequences ?
            epbernard

            use a @GenericGenerator and inject the sequence strategy and the "schema" parameter

            • 3. Re: Schemaupdate tries to create existing sequences ?

              How would I do this using current ejb3 PFD implementation?

              I'm currently using this:

              @Entity
              @Table(name="incident_category", schema="dossier")
              


              and in the class

              @Id
              @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "incident_category_seq")
              @SequenceGenerator(name = "incident_category_seq", sequenceName = "incident_category_seq")
              @Column(name = "id")
              


              and postgres is giving me this error:

              2006-02-23 15:21:58,524 DEBUG [org.hibernate.util.JDBCExceptionReporter] could not get next sequence value [select nextval ('incident_category_seq')]
              org.postgresql.util.PSQLException: ERROR: relation "incident_category_seq" does not exist
              


              • 4. Re: Schemaupdate tries to create existing sequences ?

                Well,
                changing the code to

                @SequenceGenerator(name = "incident_category_seq", sequenceName = "dossier.incident_category_seq")
                

                (changing the sequenceName to schema.sequenceName) solved this error, but I think since this did not work for the table specification, it's probably not supposed to work?