-->
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: One Spring DAO Configuration File
PostPosted: Wed Mar 07, 2007 12:08 pm 
Beginner
Beginner

Joined: Tue Jan 30, 2007 1:35 pm
Posts: 27
hi all,

I wanted to create a spring configuration file. I alrdy done the custom template and I able to create the DAO configuration. But my problem now is the configuration file will regeneate based on table. So I got lots of files, based on table which is same DAO configuration.

my ant-task:

<target name="generateDao">
<hibernatetool
destdir="${destdir}"
templatepath="${templatepath}">
&jdbcconfig;
<hbmtemplate
templateprefix="dao/"
template="dao/Dao1.ftl"
filepattern="{package-name}/{class-name}.xml">
</hbmtemplate>
</hibernatetool>
</target>

my output files :

OrdMastDAO.xml
RcptMastDAO.xml

the contents of the xml files I generated:

<bean id="RcptMastDAO" class="com.test.EntityDaoImpl">
<property name="sessionFactory" ref="test_sessionFactory" />
<property name="pkPropertyName" value="rcptNo" />
<property name="persistentClass" value="com.tables.RcptMastEO" />
</bean>

<bean id="OrdMastDAO" class="com.test.EntityDaoImpl">
<property name="sessionFactory" ref="test_sessionFactory" />
<property name="pkPropertyName" value="ordNo" />
<property name="persistentClass" value="com.tables.OrdMastEO" />
</bean>


but this 2 files..have same content..I only need 1 dao configuration file..how can I control that ??

How can I control the output file to create only 1 files ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 08, 2007 1:17 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Instead of filepattern="{package-name}/{class-name}.xml", specify an explicit filename, e.g. filepattern="applicationContext-dao.xml". Your freemarker template must loop through the entities, e.g.
Code:
<#foreach entity in c2j.getPOJOIterator(cfg.getClassMappings())>
  <bean id="${entity.shortName}DAO" class="com.test.EntityDaoImpl">
    <property name="sessionFactory" ref="test_sessionFactory" />
    <property name="pkPropertyName" value="${entity.identifierProperty.name}" />
    <property name="persistentClass" value="entity.qualifiedDeclarationName" />
</#foreach>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 09, 2007 1:08 pm 
Beginner
Beginner

Joined: Tue Jan 30, 2007 1:35 pm
Posts: 27
I tried alrdy, the xml files is not created. Too bad. Is there any method ? Please help..Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 09, 2007 2:55 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Why are you using jdbcconfig to generate your DAOs? Your mapping files and POJOs should already be generated, so use the configuration element instead. e.g. <configuration configurationfile="${dir.javasource}/hibernate.cfg.xml"/>


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.