-->
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.  [ 5 posts ] 
Author Message
 Post subject: Hbm2JavaTask not using classpath?
PostPosted: Wed Oct 27, 2004 10:53 am 
Newbie

Joined: Wed Oct 27, 2004 10:38 am
Posts: 2
When running hbm2java via ant, it never seems to be able to find user types. I have discovered that if I add the location of my classes to the ANT classpath, no problem. But if I use a nested <classpath> element in the <hbm2java> task, the classes are not found. In looking at the source code for Hbm2JavaTask.java, it appears that the classpath information is set by Ant but then the task never actually does anything with that information before calling "CodeGenerator". In other words it appears that any "classpath" information provided to the task is ignored. I am not an expert in writing Ant tasks but this seems to be a bug in Hbm2JavaTask.java. Can anyone confirm this?

Thanks,
Marion Bass


Hibernate version:
2.1.6 ext. 2.1.2
Mapping documents:
na
Code between sessionFactory.openSession() and session.close():
na
Full stack trace of any exception that occurs:
na
Name and version of the database you are using:
na
The generated SQL (show_sql=true):
na
Debug level Hibernate log excerpt:
na


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 27, 2004 12:15 pm 
Beginner
Beginner

Joined: Fri Aug 13, 2004 3:07 pm
Posts: 44
I have used the classpathref attribute in the hbm2java task.

Code:
<taskdef name="hbm2java"
               classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
               classpathref="compile.classpath" />

That seems to work fine.

_________________
Thanks
Sameet


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 27, 2004 12:38 pm 
Newbie

Joined: Wed Oct 27, 2004 10:38 am
Posts: 2
Thanks sameet for your response.

"classpathref" and "classpath" attributes of the <taskdef> task are intended to tell Ant where to find the class specified in the "classname" attribute. In otherwords, tells Ant where to find "net.sf.hibernate.tool.hbm2java.Hbm2JavaTask".

Where Hbm2JavaTask is located is totally unrelated to where my classes for UserTypes are located. The "hbm2java" task that is being defined, itself has "classpath" attribute and supports nested <classpath> specification. It is these classpath parameters to the <hbm2java> task that do nothing while it is implied that the task would use these parameters to do its work.

Code:
    <hbm2java output="${basedir}" >
      <classpath>
        <pathelement location="${classes.dir}"/>
        <fileset refid="all.lib" />
      </classpath>
      <fileset dir="${basedir}" includes="*.hbm.xml" />
    </hbm2java>


In the example above, ${classes.dir} is where my UserTypes are compiled to.

Hopefully this clarifies the issue.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 28, 2004 3:02 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i've just looked at the code in hibernateext.

It seems the code collects the classpath, but never uses it.

Make a jira entry for it - patches are welcome ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 28, 2004 3:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
but the classpathref trick mentioned above is a workaround, so unless you have two conflicting hbm2java executions then you should be ok.

(a workaround for that is to have 2 different tasknames ;)

_________________
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.  [ 5 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.