-->
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.  [ 1 post ] 
Author Message
 Post subject: hbmtemplate daohome.ftl problems when using a composite-id
PostPosted: Wed Dec 13, 2006 7:26 am 
Newbie

Joined: Tue Dec 05, 2006 8:36 am
Posts: 7
Hello,

the problem of this post is similar to http://forum.hibernate.org/viewtopic.php?t=967519, but I guess I have found the reason of the problem (though no solution yet ...)

Hibernate-Tools version: 3.2-beta8

The problem is that invoking hbmtemlate with the daohome.ftl from hibernate-tools causes an error when using a composite-id. It seems like hbmtemplate tries to create DAO classes for the composite-id classes, but fails on the undefined clazz.hasNaturalId() and clazz.entityName. (I found out the latter when removing the code for generating the findByNaturalId method from the daohome.ftl).

Is there a way to get hbmtemplate work in such a setting? I don't really know how Freemarker works and how the clazz.hasNaturalId() and clazz.entityName are affected by a mapping document, so unfortunately I'm completely helpless at this point. I've posted the error, a sample hibernate mapping document and my Ant task below. hbm2java works, but the hbmtemplate task fails.

Best Regards,
Matthias


Here's the error:


Code:
[hibernatetool] org.hibernate.tool.hbm2x.ExporterException: Error while processing template dao/daohome.ftl
[hibernatetool] freemarker.core.InvalidReferenceException: Expression clazz.hasNaturalId is undefined on line 161, column 6 in dao/daohome.ftl.



And here's an example hibernate mapping file that should cause the error with clazz.hasNaturalId(). It simply contains a composite-id with 2 key properties.


Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 28.11.2006 15:30:24 by Hibernate Tools 3.2.0.beta8 -->
<hibernate-mapping>
    <class name="eg.hibernate.CacertT" table="CACERT_T" lazy="false">
        <composite-id name="Id" class="eg.hibernate.CacertTPK">
            <key-property name="CacertIssuerId" type="java.lang.Long">
                <column name="CACERT_ISSUER_ID" />
            </key-property>
            <key-property name="CacertSerialNumber" type="java.lang.Long">
                <column name="CACERT_SERIAL_NUMBER" />
            </key-property>
        </composite-id>

    </class>
</hibernate-mapping>




for hbmtemplate I've placed all relevant folders from the hibernate-tools.jar in a hiberatetemplates folder. My Ant task looks like this:

Code:
      <hibernatetool destdir="${project.source.directory}" templatepath="${basedir}/${etc.dir}/hibernatetemplates/">
        <classpath>
          <path refid="project.run.classpath" />
          <path location="${project.source.directory}" />
        </classpath>

        <configuration configurationfile="${etc.dir}/hibernate.cfg.xml" />

        <hbm2java jdk5="true" />

        <hbmtemplate templatepath="${basedir}/${etc.dir}/hibernatetemplates/" template="dao/daohome.ftl">
          <property key="jdk5" value="true" />
          <property key="ejb3" value="false" />
        </hbmtemplate>

      </hibernatetool>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.