Hi Max,
First, thanks for your work on hibernate and user support.
max wrote:
something you want to contribute ? :)
Why not ? with the LGPL conventions of course :-)
But let's write something working first ;)
Quote:
which basePackage ? (just to be sure i know what you refer to)
I mean org.hibernate.tool.hbm2x.pojo.ImportContextImpl.basePackage, initialized by BasicPOJOClass to the POJO package. That's fine for generating POJOs, but not necessarily the expected thing when generating dao.
pojo.ImportType() is a feature of the Interface ...hbm2x.pojo.ImportContext implemented in *.hbm2x.pojo.ImportContextImpl . An instance of it is associated with the BasicPOJOClass, and the method is relayed there.
My exporter could associate and relay another instance of ImportContextImpl, initialized with the correct destination package.
Quote:
ok - don't really understand why you need that for ?
First, to generate dao classes in a different package than the POJO, but relative to it, ant get correct package declaration and imports.
Then, whatever extra-need for my new templates.
If they prove useful, I would propose to merge my work with main trunk.
Quote:
it should work. have you tried to just set exporterclass and not the template ?
Same result. The weird thing is that the trace instructions I put in both constructors don't show up in ant log, whilst they do in Junit testAntMic().
Code:
114:05:25,015 INFO HbmBinder:2375 - Mapping collection: michelp.Bank.Report.statements -> statement
14:05:25,015 INFO HbmBinder:2375 - Mapping collection: michelp.Bank.Account.reports -> report
14:05:25,046 INFO MicExporter:30 - MicExporter instance created default constructor, template is
14:05:25,046 INFO MicExporter:114 - TemplateName set to DAOFactory.java.ftl
14:05:25,046 INFO MicExporter:134 - OutputDirectory set to ..\generated
14:05:25,046 INFO MicExporter:120 - TemplatePath set to [E:\Devlp\Eclipse\workspace\MyBcq\bin\..\templates]
14:05:25,046 DEBUG MicExporter:93 - start() called
14:05:25,046 INFO MicExporter:114 - TemplateName set to dao/DAOFactory.java.ftl
14:05:25,046 INFO MicExporter:108 - FilePattern set to michelp/Bank/dao/hibernate/DAOFactory.java
14:05:25,046 DEBUG MicExporter:100 - calling super.start()
14:05:25,046 DEBUG MicExporter:132 - michelp.hbm2x.MicExporter outputdir:..\generated templatePrefix: null path: [E:\Devlp\Eclipse\workspace\MyBcq\bin\..\templates]
14:05:25,125 INFO Version:15 - Hibernate Tools 3.2.0.beta7
14:05:25,359 INFO TemplateProducer:40 - Writing dao/DAOFactory.java.ftl to E:\Devlp\Eclipse\workspace\MyBcq\bin\..\generated\michelp\Bank\dao\hibernate\DAOFactory.java
I forgot to tell about an important fix: I had to override (in MicExporter) the start() method as follows:
Code:
@Override
public void start() {
// Copy properties missing after GenericExporter.start()
log.debug("start() called");
Properties p = getProperties();
setTemplateName(p.getProperty(ExporterSettings.PREFIX_KEY
+ "template_name"));
setFilePattern(p.getProperty(ExporterSettings.PREFIX_KEY
+ "file_pattern"));
// setTemplatePrefix(???)); // Dunno how to retrieve it from here
log.debug("calling super.start()");
super.start();
}
Also I wonder why the new exporter class is created so late in process;
wouldn't be possible to avoid those properties copiing ...
did I miss something ?
--
Michelle