4 Replies Latest reply on Oct 28, 2009 1:52 AM by atamhank

    seam-gen.reveng.xml sequence entry not applied

    Luck Modlinski Newbie

      Hi, I have example table in Postgres:


      CREATE TABLE "public"."product" (
        "id" SERIAL, 
        "name" VARCHAR(255) NOT NULL, 
        "active" BOOLEAN DEFAULT true NOT NULL, 
        "store_id" INTEGER NOT NULL, 
        CONSTRAINT "product_pkey" PRIMARY KEY("id"), 
        CONSTRAINT "product_fk" FOREIGN KEY ("store_id")
          REFERENCES "public"."store"("id")
          ON DELETE RESTRICT
          ON UPDATE RESTRICT
          NOT DEFERRABLE
      ) WITHOUT OIDS;



      reveng.xml looks like this:



      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE hibernate-reverse-engineering SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
      <hibernate-reverse-engineering>
      <table name="product" schema="public" catalog="test">
         <primary-key>      
            <generator class="sequence">
           <param name="sequence">product_id_seq</param>
            </generator>
            <key-column name="id"/>
         </primary-key>
      </table>
      </hibernate-reverse-engineering>



      Now I call seam generate entities from Jboss Tools. Created entitiy doesn't have any @GenratedValue annotation. It's simple integer, wchich can be edited in generated forms (it shouldn't be):


      ...
      @Id
      @Column(name = "id", unique = true, nullable = false)
      public int getId() {
        return this.id;
      }
      ...



      I'm working on Seam 2.1.2.CR1. Please, could someone tell me why is this happening?

        • 1. Re: seam-gen.reveng.xml sequence entry not applied
          Luck Modlinski Newbie

          I see that when entities are generated by ./seam generate called in terminal, everything works fine. But if I use Jboss Tools Seam Generate Entities from project's context menu, then reveng.xml file is totally ignored. Am I missing something and Jboss Tools have it's own reverse engineering descriptor, or it's not proper behavior of IDE?

          • 2. Re: seam-gen.reveng.xml sequence entry not applied
            atamhank Newbie

            I have the same problem.


            The file seam.reveng.xml (in the hibernatetools directory) appears to make no difference in seam gen.


            here is the entry in the seam.reveng.xml



            <table name="test_table" schema="public">
               <primary-key>      
                  <generator class="sequence">
                 <param name="sequence">test_table_id1_seq</param>
                  </generator>
                  <key-column name="id"/>
               </primary-key>
            </table>
            



            here is the line in the java file created for the table and id does not seem to take notice of the sequence




            @Id
                 @Column(name = "id", unique = true, nullable = false)
                 public int getId() {
                      return this.id;
            



            Tried several permutation and combinations but still having issues. running seam generate from dos terminal does not help (I am running all commands from command line)
            Any one having any suggestions?
            thanks,
            Aaditi

            • 3. Re: seam-gen.reveng.xml sequence entry not applied
              atamhank Newbie

              This is what worked for autogeneration:


              After some experimentation this code worked for me. putting in here for others who may not have to struggle...Put this code (after changing the table names from test table to your table) in the seam.reveng.xml file



              <table name="test_table" schema ="public"> 
              
               <primary-key>
              
                 <!-- setting up a specific id generator for a table -->
              
                <generator class="sequence">
              
                  <param name="table">test_table_id1_seq</param>
              
                </generator>
              
                 <key-column name="id"/>
              
               </primary-key>
              
               </table>
              



              • 4. Re: seam-gen.reveng.xml sequence entry not applied
                atamhank Newbie

                This is how it looks like in the entity java file:


                     


                @SequenceGenerator(name = "generator")
                     @Id
                     @GeneratedValue(strategy = SEQUENCE, generator = "generator")
                     @Column(name = "id", unique = true, nullable = false)
                     public Integer getId() {
                          return this.id;
                     }



                Thanks and happy coding.
                Aaditi