首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用CustomReverseEngineeringStrategy类删除目录名的Hibernate逆向工程

问使用CustomReverseEngineeringStrategy类删除目录名的Hibernate逆向工程
EN

Stack Overflow用户
提问于 2011-12-06 07:51:24
回答 1查看 795关注 0票数 4

我使用hibernate工具库和ant脚本扩展了定制逆向工程的org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy类。在运行ant脚本之后,类将生成为-

代码语言:javascript
复制
@Entity
@Table(name="account"
    ,catalog="testdb"
)

public class Account  implements java.io.Serializable {
}

在上面的类中,catalog名称总是被添加到生成的类中。

我正在尝试使用CustomReverseEngineeringStrategy.java类删除目录名。这是我的java课程-

代码语言:javascript
复制
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类在类生成过程中删除这个目录名。你能帮我做这个吗?

EN

回答 1

Stack Overflow用户

发布于 2011-12-13 07:50:58

我用maven替换插件修复了这个问题。

也许这不是你想要的,但有效。

代码语言:javascript
复制
    <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>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8396765

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档