-->
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: Need help in customizing daohome.ftl template in hibernate
PostPosted: Sat May 12, 2012 2:17 am 
Newbie

Joined: Thu Aug 11, 2011 8:20 am
Posts: 3
Hi I am a newbie in Hibernate. I am using Hibernate Tools 3.2.4 jar with Eclipse Helios and MS SQL Server 2008.

I am trying to generate DAO class and annotated Pojos using hibernate reverse engineering.

But, currently I face few problems and I have mentioned it below

1) How to change name of DAO class generated by Hibernate Tool?

For example, if I have a table named Person I am getting the corresponding DAO class name as PersonHome. But, I want the class to be named as PersonDAO. I saw the daohome.ftl file and saw the line

public class ${declarationName}Home {

I modified that to

public class ${declarationName}DAO{

I can get the class name as PersonDAO but the problem is the file name for that particular class is still PersonHome.java

I cant find a way to change the file name. Please guide me in this issue.

2) I am trying to generate hibernate annotated pojos using hibernate reverse engineering tool. I have selected the annotation option in both Hibernate Config and in Hibernate Code Generation Configuration. But the problem is I dont see any annotations in the generated pojo. Its just a simple plain pojo without any annotation.

I have selected all the needed options in the configurations, but I still dont get a clue on why I am not getting annotated pojos.

Please help me in this ASAP.


Top
 Profile  
 
 Post subject: Re: Need help in customizing daohome.ftl template in hibernate
PostPosted: Mon May 14, 2012 11:15 am 
Senior
Senior

Joined: Fri May 08, 2009 12:27 pm
Posts: 168
I'm not using DAOs, so YMMV, but the standard way to change class names was through a ReverseEngineeringStrategy class.

However, it seems that reveng should be avoided.
It was never well-documented, particularly on what information is available to the templates via which access paths.
Right now, things are even worse since it has fallen behind Hibernate's evolution (i.e. it's incompatible with 4.x and spits out warning messages for 3.6, and I haven't seen any plans from the dev team to remedy this).
It also place some design constraints on your code, and it cannot do things like automatic backlink management (if you want that, try Cayenne).

I found I'm writing lots of manual code anyway, and the advantage of reverse engineering has dwindled.
It's good enough to create an initial version of entity classes, and indeed helpful. After that, it's going to be manual updates for us, since the automated processes simply don't work well enough to be worth the trouble. (I wish I had known that in advance, this would have saved us at least a person-month of wasted effort.)


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.