-->
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.  [ 9 posts ] 
Author Message
 Post subject: meta-element <field-description> only for get*() ?
PostPosted: Wed Sep 27, 2006 3:22 am 
Newbie

Joined: Mon Sep 18, 2006 11:36 am
Posts: 10
Location: Germany / Karlsruhe
Hi,

I'm using the meta-element in my hbm-files for placing some javadoc/XDoclet in the generated pojo:

Code:
...
<property name="label" type="string" not-null="true" >
    <meta attribute="field-description">
        @spring.validator type="required"
    </meta>
</property>
...


This javadoc is only placed above the getter-methods of the pojo, eg. getLabel().

Is there a way to place it also or explicit above the setter-method of the pojo?

Thanks in Advance,
Patrick


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 3:47 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
change the corresponding .ftl template ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 4:35 am 
Newbie

Joined: Mon Sep 18, 2006 11:36 am
Posts: 10
Location: Germany / Karlsruhe
ok, thanks.

is there a way to tell the hbm2java-task or hibernate.cfg.xml to use my custom-template (eg. MyPojoPropertyAccessor.ftl)?

thanks, patrick


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 4:38 am 
Hibernate Team
Hibernate Team

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

remember to name the exactly the same as the default ones.

e.g. pathto yourcustomtemlates/pojo/PojoPropertyAccessor.ftl

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 5:55 am 
Newbie

Joined: Mon Sep 18, 2006 11:36 am
Posts: 10
Location: Germany / Karlsruhe
maybe stupid question... is it enough to locate only this special ftl (PojoPropertyAccessor) in "mytemplatefolder/" or do i have to copy the others *.ftl from the hibernate-tool.jar there?

my task look like:
Code:
<hbm2java jdk5="true" templatepath="${src}/hibernate/template/pojo" />


template:
Code:
// Property accessors PojoPropertyAccessor
<#foreach property in pojo.getAllPropertiesIterator()>
<#if pojo.getMetaAttribAsBool(property, "gen-property", true)>
<#if pojo.hasFieldJavaDoc(property)>   
    /**       
     * ${pojo.getFieldJavaDoc(property, 4)}
     */
</#if>
    <#include "Ejb3PropertyGetAnnotation.ftl"/>
    ${pojo.getPropertyGetModifiers(property)} ${pojo.getJavaTypeName(property, jdk5)} ${pojo.getGetterSignature(property)}() {
        return this.${property.name};
    }

<#if pojo.hasFieldJavaDoc(property)>   
    /**       
     * ${pojo.getFieldJavaDoc(property, 4)}
     */
</#if>
    <#include "Ejb3PropertyGetAnnotation.ftl"/>
    ${pojo.getPropertySetModifiers(property)} void set${pojo.getPropertyName(property)}(${pojo.getJavaTypeName(property, jdk5)} ${property.name}) {
        this.${property.name} = ${property.name};
    }
</#if>
</#foreach>


but the task didn`t recognize my template. also no error messages...

patrick


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 6:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you just need to copy the files you have changed.

And follow the pattern i used in my last posting with respect to templatepath and the actual path to the template.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 6:39 am 
Newbie

Joined: Mon Sep 18, 2006 11:36 am
Posts: 10
Location: Germany / Karlsruhe
hi max,

Quote:
<hbm2java jdk5="true" templatepath="${src}/hibernate/template/pojo" />

should be
Code:
<hbm2java jdk5="true" templatepath="${src}/hibernate/template" />


my ftl is located as follows:
${src}/hibernate/template/pojo/PojoPropertyAccessor.ftl

but it doesn't work...
maybe there is a classpath needed??

hope not to bother you... ;-)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 7:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
probably because the original file is named pojo/PojoPropertyAccessors.ftl
and not pojo/PojoPropertyAccessor.ftl (small, but important detail ...notice the lack of s ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 7:47 am 
Newbie

Joined: Mon Sep 18, 2006 11:36 am
Posts: 10
Location: Germany / Karlsruhe
damn!! my fault... i should go sleeping ;-)
... now it works.

thanks you.
patrick


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.