我使用hibernate工具库和ant脚本扩展了定制逆向工程的org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy类。在运行ant脚本之后,类将生成为-
@Entity
@Table(name="account"
,catalog="testdb"
)
public class Account implements java.io.Serializable {
}在上面的类中,catalog名称总是被添加到生成的类中。
我正在尝试使用CustomReverseEngineeringStrategy.java类删除目录名。这是我的java课程-
public class CustomReverseEngineeringStrategy extends DelegatingReverseEngineeringStrategy {
public Map<String, MetaAttribute> tableToMetaAttributes(TableIdentifier tableIdentifier){
Map<String, MetaAttribute> metaAttributes = super.tableToMetaAttributes(tableIdentifier);
if (metaAttributes == null) {
metaAttributes = new HashMap<String, MetaAttribute>();
}
String catalogName = tableIdentifier.getCatalog();
if(metaAttributes.containsKey(catalogName)){
System.out.print(catalogName);
metaAttributes.remove(catalogName);
}
return metaAttributes;
}
}在此tableIdentifier中返回目录名。但是,没有设置目录名称的方法。此外,metaAttributes不包含目录名称的键。
我想使用CustomReverseEngineeringStrategy类在类生成过程中删除这个目录名。你能帮我做这个吗?
发布于 2011-12-13 07:50:58
我用maven替换插件修复了这个问题。
也许这不是你想要的,但有效。
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>(version)</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<regex>false</regex>
<token>,catalog="testdb"</token>
<value></value>
</configuration>
</plugin>https://stackoverflow.com/questions/8396765
复制相似问题