-->
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: Add extra code in DAOs
PostPosted: Mon Sep 08, 2008 12:03 pm 
Newbie

Joined: Mon Sep 08, 2008 11:50 am
Posts: 12
Hello,

I want to know how I can add extra code in the DAOs.

In the pojo class is simple:

Code:
<#if pojo.hasMetaAttribute("class-code")>  // The following is extra code specified in the hbm.xml files
${pojo.getExtraClassCode()}
  // end of extra code specified in the hbm.xml files
</#if>


I put this code in the daohome.ftl:

Code:
<#if pojo.hasMetaAttribute("dao-code")>
${pojo.getMetaAsString("dao-code")}
</#if>


And put this meta tag in the hbm.xml:

Code:
<meta attribute="dao-code">
           <![CDATA[
               /**
               * Add an airport to this country
               */
               public void addAirport(Airport airport) {
               airport.setCountry(this);
               if (airports == null) {
               airports = new java.util.HashSet();
               }
               airports.add(airport);
               }
           ]]>
</meta>


But it doesn't work.

Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2008 10:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
are you sure your modified tempalte gets picked up ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2008 12:04 pm 
Newbie

Joined: Mon Sep 08, 2008 11:50 am
Posts: 12
Max, thanks for reply.

max wrote:
are you sure your modified tempalte gets picked up ?


This is my target in the build.xml:

Code:
<target name="daoimplgen.template" depends="daogen.template">
      <hibernatetool destdir="${javagenerated}">
         <configuration configurationfile="${configgenerated}/hibernate.cfg.xml" />
         <hbmtemplate templatepath="templates" template="dao/daohome.ftl" filepattern="{package-name}/dao/impl/{class-name}HBDAO.java ">
            <property key="jdk5" value="true" />
            <property key="ejb3" value="false" />
            <property key="sessionFactoryName" value="SessionFactory" />
         </hbmtemplate>
      </hibernatetool>
   </target>


I have the 'templates' directory with all freemarker templates.

Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2008 12:10 pm 
Newbie

Joined: Mon Sep 08, 2008 11:50 am
Posts: 12
Max, you are right. I read another hbm.xml file and not read the dao code.

Thanks for everything.


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.