4 Replies Latest reply on Sep 18, 2012 10:21 PM by nicotexas

    Hibernate Tools 4 Alpha @SequenceGenerator unique name ?

    nicotexas Newbie

      Hi,  I'm trying to get hbm2java (Eclipse tools 4) to generate my entities with EJB3 annotations to get the @GeneratedValue and @SequenceGenerator for my primary keys. 

       

      Right now when generating my POJOs I get 

       

      @SequenceGenerator(name = "generator", sequenceName = "S_CLIENT")

         @Id

         @GeneratedValue(strategy = SEQUENCE, generator = "generator")

         @Column(name = "CLIENT_ID", unique = true, nullable = false, precision = 22, scale = 0)

         public long getClientId() {

            return this.clientId;

         }

       

       

      Look OK but the problem is  generator = "generator" that will be the same for every POJO hbm2java generates.

      I can't find any way to set the name for the SequenceGenerator. 

       

      Tried with reveng.xml      

       

         <primary-key>     

            <generator class="sequence">     

               <param name="sequence">S_CLIENT</param>

            </generator>

           

         </primary-key>

        

         <column name="CLIENT_ID" >

            <meta attribute="use-in-equals">true</meta>

            <meta attribute="use-in-tostring">true</meta>

           

         </column>

               

       

      and DelegatingReverseEngineeringStrategy     

       

      @Override

         public Properties getTableIdentifierProperties(TableIdentifier identifier) {

           

            //@SequenceGenerator(name="APP_DEVDB_APPDEVDBID_GENERATOR", sequenceName="S_APP_DEVDB")

            Properties properties = new Properties();     

            properties.put("sequence", "S_"+identifier.getName());     

                      properties.put("name", "Generator"+identifier.getName());

            return properties;

         }

        

         public String getTableIdentifierStrategyName(TableIdentifier identifier) {

               return "sequence";

         }

       

       

       

      Any way to change that behavior?  Thanks....