-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Tools EJB3 Annotation generated duplicates SequenceGenerator
PostPosted: Wed Sep 12, 2012 1:43 pm 
Newbie

Joined: Mon Sep 10, 2012 6:16 pm
Posts: 2
Hi,

I'm trying to get hbm2java (Eclipse tools 3.5) 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
Code:
@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
Code:
generator = "generator"
that will be the same for every POJO hbm2java generates and JPA 2.0 doens't "like" it.
I can't find any way to set the name for the SequenceGenerator.

Tried with reveng.xml
Code:
<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

Code:
   @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....


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.