-->
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.  [ 4 posts ] 
Author Message
 Post subject: Is it possible to exclude "field-description" from
PostPosted: Tue Apr 04, 2006 9:40 pm 
Beginner
Beginner

Joined: Sun Oct 05, 2003 9:07 am
Posts: 47
Hibernate Tools version: 3.1.0 Beta 4

I have the following code that's produced by Middlegen 2.1 (I know it's old school, but I don't believe the Hibernate Tools project supports generating XDoclet-enhanced POJOs).

Code:
    <id
        name="catId"
        type="java.lang.Integer"
        column="cat_id"
    >
        <meta attribute="field-description">
           @hibernate.id
            generator-class="native"
            type="java.lang.Integer"
            column="cat_id"

        </meta>
        <meta attribute="use-in-equals">true</meta>
        <generator class="native" />
    </id>


When I use hbm2java, I end up with the XDoclet tags on my fields, as well as my getter methods. Is it possible to exclude them from the fields w/o hacking the Velocity template? Here's what I've done to exclude them for now. Changed PojoFields.vm from:

Code:
#foreach($field in $pojo.getAllPropertiesIterator())
#if($pojo.getMetaAttribAsBool($field, "gen-property", true))
#if($pojo.hasMetaAttribute($field, "field-description"))
    /**
     $pojo.getFieldJavaDoc($field,0)
     */
#end
    $pojo.getFieldModifiers($field) $pojo.getJavaTypeName($field, $jdk5) $field.name#if($pojo.hasFieldInitializor($field, $jdk5)) = $pojo.getFieldInitialization($field, $jdk5)#end;
#end
#end


To:
Code:
#foreach($field in $pojo.getAllPropertiesIterator())
#if($pojo.getMetaAttribAsBool($field, "gen-property", true))
    $pojo.getFieldModifiers($field) $pojo.getJavaTypeName($field, $jdk5) $field.name#if($pojo.hasFieldInitializor($field, $jdk5)) = $pojo.getFieldInitialization($field, $jdk5)#end;
#end
#end


Is there a more elegant solution?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 04, 2006 9:56 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
what is inelegant about you adjusting the templates to what you want ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 04, 2006 10:08 pm 
Beginner
Beginner

Joined: Sun Oct 05, 2003 9:07 am
Posts: 47
max wrote:
what is inelegant about you adjusting the templates to what you want ?


Nothing really, actually it's quite easy. However, it's not very maintainable on my part since I'll have to modify them for every release. Unless, of course, there's a way to override the default template with one of my own.

Thanks,

Matt


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 05, 2006 6:02 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
look for templatepath in the docs.

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