Using HibernateTools3.1.0Beta1.
Trying to figure out best way to add an exporter without modifying code but rather extending the toolset. Is there a way?
My particular need for the custom exporter is explained below.
I'm trying to figure out which is the best way to programmatically set the meta attribute "use-in-equals" on properties. Basically, I know I want to do some code like this:
Code:
property.getMetaAttributes().put("use-in-equals", meta);
1) Is the above code the best way to do this?
2) Which is the best place to put the code? Preferably extending the classes rather than rewriting them would be better.
I originally thought of creating my own MyHbm2JavaGeneratorTask class and MyHibernateToolTask classes. The plan was to have MyHbernateToolTask derive from HibernateToolTask and just add this method:
Code:
public ExporterTask createMyHbm2Java() {
ExporterTask generator = new MyHbm2JavaGeneratorTask(this);
generators.add(generator);
return generator;
}
MyHbm2JavaGeneratorTask.confiureExporter would programmatically add the "use-in-equals" meta attribute.
Unfortunately, the
generators member field is private in the super class HibernateToolTask, so I couldn't do it this way. The other solution that does work is to just create a new class parallel, instead of derived, to the HibernateToolTask and duplicate all the code and add my extra method. This, however, was what I didn't want to do since it involved changing the existing code.
So, essentially, I think my problem can be more generally stated as how does one add a custom exporter task by extending the toolset rather than modifying it? Is there a way?
Any help is appreciated.
Thank You.