I would like to generate a customized DAO which extends ClassA and implements SampleInterface. The SampleInterface has a method which should be implemented while generating this DAO. And also the naming convention of the DAO's I generate should have DAO at the end in the class name but not "Home", as the hibernate tools generate the DAO Classes with Home at the end by default.
My table Names are Employee, Address, Salary and I have my entity generated and they are in com.mycompany.model package. Currently I have Address, Employee, Salary Entities with all the annotations and mapping in it. I want to generate AddressDAO, EmployeeDAO and SalaryDAO using below reverse engineering strategy.
Below is my Reverse Engineering Strategy class
public class DAOReverseEngineeringStrategy extends
DelegatingReverseEngineeringStrategy {
public DAOReverseEngineeringStrategy(ReverseEngineeringStrategy delegate) {
super(delegate);
// TODO Auto-generated constructor stub
}
@Override
public Map tableToMetaAttributes(final TableIdentifier tableIdentifier) {
Map<String, MetaAttribute> metaAttributes = super
.tableToMetaAttributes(tableIdentifier);
if (metaAttributes == null) {
metaAttributes = new HashMap<String, MetaAttribute>();
}
MetaAttribute attributeExtends = new MetaAttribute("extends");
attributeExtends.addValue("ClassA");
metaAttributes.put("extends", attributeExtends);
MetaAttribute attributeImpl = new MetaAttribute("implements");
attributeImpl.addValue("SampleInterface");
metaAttributes.put("implements", attributeImpl);
MetaAttribute attributeImport = new MetaAttribute("extra-import");
attributeImport.addValue("com.mycompany.ClassA");
attributeImport.addValue("com.mycompany.SampleInterface");
attributeImport.addValue("com.mycompany.model.*");
metaAttributes.put("extra-import", attributeImport);
return metaAttributes;
}
}