-->
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.  [ 6 posts ] 
Author Message
 Post subject: override pojo/Pojo.ftl
PostPosted: Tue Mar 11, 2008 11:58 pm 
Newbie

Joined: Tue Mar 11, 2008 11:51 pm
Posts: 3
Hi,

I want to use a different pojo/Pojo.ftl. Currently I do this by replacing the version in hibernate-tools.jar with my own version, but that is of course not nice. I read about <hbmtemplate>, but can't make it work so that I can just specify that one file. I tried various combinations of template and templatepath attributes, but it either does not use my ftl at all or it fails because it expects all ftl files to be in that location.

Any idea/hints?

Best,
Norbert


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 12, 2008 8:09 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
use templatepath="yourrootdir"

copy pojo/Pojo.ftl to yourrootdir/pojo/Pojo.ftl

Then it will pick up this Pojo.ftl first and then any other templates that is not to be found in yourrootdir/* will be taken from the jar.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 12, 2008 2:26 pm 
Newbie

Joined: Tue Mar 11, 2008 11:51 pm
Posts: 3
Thanks for the quick answer. I tried this with etc/hbm/pojo/Pojo.ftl, but get the following error:

Quote:
[hibernatetool] INFO: Hibernate Tools 3.2.0.beta8
[hibernatetool] An exception occurred while running exporter #2:generic exporter
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.tool.hbm2x.ExporterException: File pattern not set on class org.hibernate.tool.hbm2x.GenericExporter


I also ran it through strace and ant does not even try to access Pojo.ftl before this error shows up.

The ant target I'm using is:
Code:
<target name="hbm2java" description="generate Java code from hbm files">
      <hibernatetool destdir="javasrc">
         <classpath path="javasrc" />
            <hbmtemplate templatepath="etc/hbm" />
         <configuration configurationfile="javasrc/hibernate.cfg.xml" />
         <hbm2java jdk5="true" />
      </hibernatetool>
   </target>


</nk>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 12, 2008 5:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I think what you really want is:

Code:
<target name="hbm2java" description="generate Java code from hbm files">
      <hibernatetool destdir="javasrc">
         <classpath path="javasrc" />
         <configuration configurationfile="javasrc/hibernate.cfg.xml" />
         <hbm2java templatepath="etc/hbm" jdk5="true" />
      </hibernatetool>
   </target>


Don't know what that extra hbmtemplate were doing there? :)

p.s. also not sure your classpath should be path="javasrc" ...you dont have classes in there do you ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 12, 2008 5:32 pm 
Newbie

Joined: Tue Mar 11, 2008 11:51 pm
Posts: 3
Thanks a lot, works like a charm!

Regarding the classpath: I store the hbm.xml files inside the same directories where the other java files live (and where I also generate the pojos). Is there a better way than classpath to specify where hibernate should look for hbm files?

BTW: I got that <hbmtemplate> from http://www.hibernate.org/hib_docs/tools/reference/en/html_single/#d0e890


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 3:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
nkiesel wrote:
Regarding the classpath: I store the hbm.xml files inside the same directories where the other java files live (and where I also generate the pojos). Is there a better way than classpath to specify where hibernate should look for hbm files?


Sure, it needs a classpath but I would just assume that your hbm.xml files would be copied over into the normal classpath....using the src location is fine if that is the only place they are at this point of the build process.

Quote:


Yes, and that one has all the required attributes listed, yours hasn't ;)

Plus it is not the generic hbmtemplate you wanted but just customize <hbm2java>.

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