Using Hibernate 3.1 Beta1
This is related to generating java code from hbm.xml files. I created my own POJOExporter class. I'm getting an error running my Custom exporter with the hbmtemplate tool (using HibernateToolTask). However, the error is just:
Code:
org.hibernate.tool.hbm2x.ExporterException: Could not instantiate exporter of class MyPOJOExporter
I get this error after it gets through mapping a bunch of my files. The last things I see before the error message is:
Code:
Nov 22, 2005 12:29:11 PM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
If anybody has a clue about this, please let me know. In the meantime, I'm trying to debug this by launching my custom exporter programmatically (vs ANT) so that I can put it through a debugger. Does anybody have the code to do the same thing as the ant call? Essentially I want to do the following in code rather than in ANT:
Code:
<hibernatetool destdir="[output dir]">
<classpath> <!-- a classpath is optional, but needed for exporters that require access to domain classes etc. -->
<path location="[classpath of needed classes, such as domain classes and usertypes - dependent on the chosen exporter]"/>
</classpath>
<configuration configurationfile="hibernate.cfg.xml" >
<fileset dir="${src.dir}/../test" id="id"> <!-- A configuration can take a configurationfile and/or a fileset of hbm.xml's -->
<include name="**/*TopDown.hbm.xml"/>
</fileset>
</configuration>
<hbmtemplate template="pojo.vm" exporterclass="MyoPOJOExporter" filepattern="{package-name}/{class-name}"/>
</hibernatetool>
I've come up with the following so far, but it keeps complaining about lazy attribute in my hbm.xml files not having values of "false proxy no-proxy", even though I've fixed them in the files.
Code:
Caused by: org.xml.sax.SAXParseException: Attribute "lazy" with value "true" must have a value from the list "false proxy no-proxy ".
Maybe, I'm not picking up the right libraries of hibernate now that I'm not using Ant? Although I think I am. So, since this is a different error than I'm getting running with ANT, I'm thinking I haven't written the right code to duplicate the ANT behaviour.
Here is my code:
Code:
public MyHibernateToolTask() {
this.setProject(new Project());
this.getProject().init();
this.setDestDir(new File("C:/temp"));
Path path = new Path(this.getProject());
// path.setPath("C:/save/development;C:/Temp/");
this.setClasspath(path);
ConfigurationTask configTask = this.createConfiguration();
configTask.setProject(this.getProject());
configTask.setConfigurationFile(new File("C:/save/development/hibernate.cfg.xml"));
FileSet fileSet = new FileSet();
fileSet.setDir(new File("C:/save/development/Eclipse_Projects"));
fileSet.createInclude().setName("**/*.hbm.xml");
configTask.addConfiguredFileSet(fileSet);
//configTask.getConfiguration().buildMappings();
GenericExporterTask generator = (GenericExporterTask)this.createHbmTemplate();
generator.setExporterClass("MyPOJOExporter");
generator.setTemplate("pojo.vm");
generator.setFilePattern("{package-name}/{class-name}");
}
}
MyHibernateToolTask task = new MyHibernateToolTask();
task.execute();
If anybody has any ideas, please help! :)
Thanks.