Java – hibernate reverse engineering uses the customreverseengineeringstrategy class to delete directory names
•
Java
I use hibernate tool library and ant script to extend org hibernate. cfg. reveng. Delegatingreverseengineeringstrategy class, used to customize reverse engineering
@Entity @Table(name="account",catalog="testdb" ) public class Account implements java.io.Serializable { }
In the above class directory, names are always added to the generated classes
I tried to use customreverseengineeringstrategy The Java class deletes the directory name This is my java class –
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; } }
Return the directory name in this tableidentifier However, there is no way to set the directory name Metaattributes also do not contain keys for directory names I want to use the customreverseengineeringstrategy class to remove this directory name during class generation Can you help me?
Solution
I fixed this problem by using Maven - replace - plugin
Maybe that's not what you're asking, but it does work
<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>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码