-->
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: Ant and hbm-Metainformation
PostPosted: Mon Sep 18, 2006 11:47 am 
Newbie

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

I'm pretty new to hibernate.

I would like to know what variables representing hbm-metainformation are available in the ant-task "hbmtemplate".
In the docs i only found "class-name" and "package-name".

In this Ant-task I require the value which returns ${pojo.getShortName()} in my Template.

Any ideas?
Thanks in Advance.

Patrick


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 18, 2006 12:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
class-name and package-name is for the filepattern.

all of the rest are very much used in the templates and doesn't ${pojo.getShortName()} work for you in your template?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 19, 2006 5:40 am 
Newbie

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

the problem is, that i want to use my hibernate-pojos as base-classes (eg. mydomain.model.PersonBase) and extend them with classes like mydomain.model.Person for implementing specific issues.

Hibernate-Mapping
Code:
<hibernate-mapping>
    <class name="Person">
      <meta attribute="generated-class">mydomain.model.PersonBase</meta>
        <id name="id" type="int">
            <generator class="native"></generator>
        </id>
        <property name="name" type="string"></property>
    </class>
</hibernate-mapping>


Ant-Task
Code:
<target name="hibernate-pojos" >
    <hibernatetool destdir="${src}">
    <configuration configurationfile="src/hibernate/hibernate.cfg.xml"/>
           <hbm2java/>
       </hibernatetool>
</target>


--> this outputs mydomain/model/PersonBase.java

Up to now everything is fine.
Now I want to generate the sublass Person from following template PojoSubclass.ftl.

Template
Code:
${pojo.getPackageDeclaration()};

public class ${pojo.getShortName()} extends ${pojo.getDeclarationName()}
       implements java.io.Serializable {

    /** default constructor */
    public ${pojo.getShortName()}() {
    }
}


...with Ant-Task
Code:
<target name="hibernate-subclass-pojos" >
   <hibernatetool destdir="${src}">
       <configuration configurationfile="src/hibernate/hibernate.cfg.xml"/>
          <hbmtemplate
           filepattern="{package-name}/{class-name}.java"
           template="PojoSubclass.ftl"
          />
       </hibernatetool>
   </target>


Now I have the problem, that the extended class will be named as the superclass (PersonBase) and overwrites it. So i need an expression in filepattern which represents "Person" and not "PersonBase" (like {class-name} does).

Greets Patrick


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 19, 2006 5:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
for your specifc case you could just do:

Code:
filepattern="{package-name}/{class-name}Base.java"


if you look in the jira there is a issue we need to solve that is about this exact issue.

We probably need to evaluate the filepattern "inside" the same template context allowing you to use freemarker syntax.

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