-->
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.  [ 3 posts ] 
Author Message
 Post subject: Adapt pojo generation
PostPosted: Mon Jun 18, 2007 4:02 am 
Regular
Regular

Joined: Wed Nov 01, 2006 2:17 pm
Posts: 78
Hi,

I am using a slightly adapted FTL-template (Pojo.ftl) to generate DTOs. So on first attempt I tried to name all the files "xyDTO.java"; the same with the class-names. This works fine:

Code:
         <!-- Generate DTOs -->
            <hbmtemplate
               filepattern="../../shared/dto/{class-name}DTO.java"
               templatepath="${templatepath}/dto"
               template="DTO.ftl">
               <property key="jdk5" value="true" />
               <property key="ejb3" value="false" />         
               <property key="package" value="org.mycompany.mysoftware.shared.dto" />
            </hbmtemplate>


But when it comes to the field declarations, the entity names instead of xyDTO are inserted for this part of the template:

Code:
    // Fields   

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


Simply putting a DTO at the end of the JavaTypeName transforms primitive dataypes too: intDTO. This is NOT what I want to achieve. I just want to have the fields and property accessors of my entities named like "MyReferencedEntityDTO" instead of "MyReferencedEntity".

How is this possible please?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 21, 2007 2:50 am 
Regular
Regular

Joined: Wed Nov 01, 2006 2:17 pm
Posts: 78
Anybody any idea?

How can I differentiate Hibernate entities from normal JAVA classes within my template? Only the Hibernate entities should end with a DTO.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 22, 2007 3:20 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
c2j.isManyToOne(property) ?

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