-->
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.  [ 7 posts ] 
Author Message
 Post subject: custom codegen - howto?
PostPosted: Thu Jan 10, 2008 12:06 am 
Newbie

Joined: Wed Jan 09, 2008 11:30 pm
Posts: 9
I would like to change the codegen to use the same layout as I am used to, eg that output by the 'hibernate synchronizer' plugin for eclipse.

I've used freemarker before, so making my own templates shouldnt be a problem, but what else do I need to do?

a java class implement a custom codegen strategy?

Nick

ps; the system I am used to uses
project/data/Domain_Objects.java
project/data/DAO/DomainObjectDao.java
project/data/DAO/iface/DomainObjectDao.java
project/data/base/BaseDomainObject.java
project/data/base/BaseDomainObjectDao.java


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 10, 2008 5:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
that is just about changing the dao templates.

I would recommend using <hbmtemplate> to generate the various parts.

Look at the docs plus the existing templates to see how things are done.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 10, 2008 4:36 pm 
Newbie

Joined: Wed Jan 09, 2008 11:30 pm
Posts: 9
Thank you Max,

Could you suggest a way of generating two different files per entity?
I cant quite see how that should work.

Is there a more elegant method than using ant to run the whole thing twice?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 10, 2008 5:45 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh you can have multiple exporters per run....

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 10, 2008 8:59 pm 
Newbie

Joined: Wed Jan 09, 2008 11:30 pm
Posts: 9
I think I'm getting pretty deep into "palm => forehead" territory here...


Top
 Profile  
 
 Post subject: movig along
PostPosted: Thu Jan 10, 2008 10:22 pm 
Newbie

Joined: Wed Jan 09, 2008 11:30 pm
Posts: 9
I have an error:

Loaded from /home/nick/repos/a/src/WEB-INF/lib/freemarker.jar freemarker/cache/TemplateCache$TemplateKey.class
Class freemarker.cache.TemplateCache$TemplateKey loaded from ant loader (parentFirst)
Couldn't load Resource home/nick/repos/a/hibernate-tools/templates/hbm2java/BaseDomainObject_en_NZ.ftl
Couldn't load Resource home/nick/repos/a/hibernate-tools/templates/hbm2java/BaseDomainObject_en.ftl
Couldn't load Resource home/nick/repos/a/hibernate-tools/templates/hbm2java/BaseDomainObject.ftl
[hibernatetool] An exception occurred while running exporter #2:generic exportertemplate: /home/nick/repos/a/hibernate-tools/templates/hbm2java/BaseDomainObject.ftl
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.tool.hbm2x.ExporterException: Error while processing template /home/nick/repos/a/hibernate-tools/templates/hbm2java/BaseDomainObject.ftl
[hibernatetool] java.io.FileNotFoundException: Template /home/nick/repos/a/hibernate-tools/templates/hbm2java/BaseDomainObject.ftl not found.
Class java.lang.UnsupportedClassVersionError loaded from parent loader (parentFirst)

the relevant part of the ant build.xml:

<configuration configurationfile="${basedir}/../src/WEB-INF/classes/hibernate.cfg.xml"/>
<hbmtemplate
filepattern="${package-name}/base/base${class-name}.java"
template="${basedir}/templates/hbm2java/BaseDomainObject.ftl"/>

and some console output:

nick@nick-desktop:~/repos/a/hibernate-tools$ ls -l /home/nick/repos/a/hibernate-tools/templates/hbm2java/BaseDomainObject.ftl
-rw-r--r-- 1 nick nick 112 2008-01-11 14:11 /home/nick/repos/a/hibernate-tools/templates/hbm2java/BaseDomainObject.ftl

Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 10, 2008 10:54 pm 
Newbie

Joined: Wed Jan 09, 2008 11:30 pm
Posts: 9
Never mind - fount it

templatepath=...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.