-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Code Gen: Help running/debug custom exporter(hbmtemplate)
PostPosted: Tue Nov 22, 2005 4:49 pm 
Beginner
Beginner

Joined: Tue Nov 15, 2005 6:56 pm
Posts: 39
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 23, 2005 8:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
what did you change the lazy value to ?

The exporter construction probably fails because you either dont have the full classname there or you did not add the exporter class to your classpath.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.