java – Hibernate逆向工程使用CustomReverseEngineeringStrateg
发布时间:2020-12-15 02:29:44 所属栏目:Java 来源:网络整理
导读:我使用hibernate工具库和ant脚本扩展了org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy类,用于自定义逆向工程. 运行ant脚本后,类生成为 – @Entity@Table(name="account",catalog="testdb")public class Account implements java.io.Seriali
我使用hibernate工具库和ant脚本扩展了org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy类,用于自定义逆向工程.
运行ant脚本后,类生成为 – @Entity @Table(name="account",catalog="testdb" ) public class Account implements java.io.Serializable { } 在上面的类目录中,始终会在生成的类中添加名称. 我试图使用CustomReverseEngineeringStrategy.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中返回目录名称.但是,没有方法来设置目录名称. 解决方法
我通过使用maven-replacer-plugin修复了这个问题.
也许这不是你要问的,但它确实有效. <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> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |