<table cellspacing='0' cellpadding='0' border='0' background='none' style='font-family:arial;font-size:10pt;color:rgb(51, 51, 51);background-color:rgb(255, 255, 255);width:100%;'><tr><td valign='top' style='font: inherit;'>Hi,<br><br>I am experiencing a problem with the package name declaration during pojo and mapping generation with Hibernate Tools without using Ant.<br><br><span style="font-weight: bold;">hibernate.cfg.xml:</span><br><br><span class="postbody">
<?xml version="1.0" encoding="UTF-8"?>
<br>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate
Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<br>
<hibernate-configuration>
<br>
<session-factory name="session1">
<br>
<property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
<br>
<property name="hibernate.connection.driver_class">org.apache.derby.jdbc.ClientDriver</property>
<br>
<property name="hibernate.connection.url">jdbc:derby://localhost:1527/travel</property>
<br>
<property name="hibernate.connection.username">travel</property>
<br>
<property name="hibernate.connection.password">travel</property>
<br>
</session-factory>
<br>
</hibernate-configuration>
<br><br><span style="font-weight: bold;">hibernate.reveng.xml:</span><br><br></span><span class="postbody">
<?xml version="1.0" encoding="UTF-8"?>
<br>
<!DOCTYPE hibernate-reverse-engineering PUBLIC
"-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">
<br>
<hibernate-reverse-engineering>
<br>
<table-filter exclude="false" match-catalog=".*" match-name="FLIGHT" match-schema=".*"/>
<br>
<table-filter exclude="false" match-catalog=".*" match-name="PERSON" match-schema=".*"/>
<br>
<table-filter exclude="false" match-catalog=".*" match-name="TRIP" match-schema=".*"/>
<br>
<table-filter exclude="false" match-catalog=".*" match-name="TRIPTYPE" match-schema=".*"/>
<br>
</hibernate-reverse-engineering>
<br><br><br><span style="font-weight: bold;">Code that generates pojos and mapping files:</span><br><br>try {<br> cfg = new JDBCMetaDataConfiguration();<br> OverrideRepository or = new OverrideRepository();<br> InputStream xmlInputStream = new FileInputStream(FileUtil.toFile(revengFile));<br> xmlHelper = new XMLHelper();<br> entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER;<br> List errors = new
ArrayList();<br><br> SAXReader saxReader = xmlHelper.createSAXReader("XML InputStream", errors, entityResolver);<br> org.dom4j.Document doc = saxReader.read(new InputSource(xmlInputStream));<br> Configuration c = cfg.configure(confFile);<br> cfg.setReverseEngineeringStrategy(or.getReverseEngineeringStrategy(new DefaultReverseEngineeringStrategy()));<br> cfg.readFromJDBC();<br> } catch (Exception e)
{<br> Exceptions.printStackTrace(e);<br> }<br><br> // Generating POJOs<br> FileObject pkg;<br> try {<br> pkg = SourceGroups.getFolderForPackage(helper.getLocation(), helper.getPackageName());<br> File outputDir = FileUtil.toFile(pkg);<br> POJOExporter exporter = new POJOExporter(cfg,
outputDir);<br> exporter.getProperties().setProperty("jdk", new Boolean(helper.getJavaSyntax()).toString());<br> exporter.getProperties().setProperty("ejb3", new Boolean(helper.getEjbAnnotation()).toString());<br> exporter.start();<br> } catch (IOException ex) {<br> Exceptions.printStackTrace(ex);<br> }<br><br> // Generate Mappings<br> try
{<br> pkg = SourceGroups.getFolderForPackage(helper.getLocation(), helper.getPackageName()); <br> File outputDir = FileUtil.toFile(pkg);<br> HibernateMappingExporter exporter = new HibernateMappingExporter(cfg, outputDir); <br> exporter.start();<br> } catch (Exception e)
{<br> Exceptions.printStackTrace(ex);<br> }<br></span><br>in the code <span class="postbody">outputDir is <br>C:\Documents and Settings\gowri\MyDocuments\NetBeansProjects\WebApplication57\src\java\Travel.<br><br>But the generated pojo and mapping files don't contain package as Travel .<br><br>// default package<br>// Generated May 27, 2008 12:45:56 AM by Hibernate Tools 3.2.1.GA<br><br><br>import java.util.Date;<br><br>/**<br> * Person generated by hbm2java<br> */<br>public class Person implements java.io.Serializable {<br><br><br> private int personid;<br> private String name;<br> private String jobtitle;<br> private Short frequentflyer;<br> private Date
lastupdated;<br><br> public Person() {<br> }<br><br> <br> public Person(int personid) {<br> this.personid = personid;<br> }<br> public Person(int personid, String name, String jobtitle, Short frequentflyer, Date lastupdated) {<br> this.personid = personid;<br> this.name = name;<br> this.jobtitle = jobtitle;<br> this.frequentflyer = frequentflyer;<br> this.lastupdated = lastupdated;<br> }<br><br><br><?xml version="1.0"?><br><!DOCTYPE hibernate-mapping PUBLIC <br> "-//Hibernate/Hibernate Mapping DTD 3.0//EN"<br>
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><br><br><!-- Generated May 27, 2008 12:45:57 AM by Hibernate Tools 3.2.1.GA --><br><hibernate-mapping><br><br><class name="Person" table="PERSON" schema="TRAVEL"><br> <id name="personid" type="int"><br> <br><br><br>class name should be Travel.Person. <br><br>Wondering why tools is not setting the package right ?<br><br>Secondly, even though I have defined the HibernateReverseEngineeringStrategy, why tools is generating pojos and mapping files for all the tables in the db ? (Note:I have listed only selected tables in the hibernate.reveng.xml).<br><br></span></td></tr></table><br>