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 achieve that?
Thanks....