Hi,

I am experiencing a problem with the package name declaration during pojo and mapping generation with Hibernate Tools without using Ant.

hibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="session1">
<property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
<property name="hibernate.connection.driver_class">org.apache.derby.jdbc.ClientDriver</property>
<property name="hibernate.connection.url">jdbc:derby://localhost:1527/travel</property>
<property name="hibernate.connection.username">travel</property>
<property name="hibernate.connection.password">travel</property>
</session-factory>
</hibernate-configuration>

hibernate.reveng.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">
<hibernate-reverse-engineering>
<table-filter exclude="false" match-catalog=".*" match-name="FLIGHT" match-schema=".*"/>
<table-filter exclude="false" match-catalog=".*" match-name="PERSON" match-schema=".*"/>
<table-filter exclude="false" match-catalog=".*" match-name="TRIP" match-schema=".*"/>
<table-filter exclude="false" match-catalog=".*" match-name="TRIPTYPE" match-schema=".*"/>
</hibernate-reverse-engineering>


Code that generates pojos and mapping files:

try {
                cfg = new JDBCMetaDataConfiguration();
                OverrideRepository or = new OverrideRepository();
                InputStream xmlInputStream = new FileInputStream(FileUtil.toFile(revengFile));
                xmlHelper = new XMLHelper();
                entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER;
                List errors = new ArrayList();

                SAXReader saxReader = xmlHelper.createSAXReader("XML InputStream", errors, entityResolver);
                org.dom4j.Document doc = saxReader.read(new InputSource(xmlInputStream));
                Configuration c = cfg.configure(confFile);
                cfg.setReverseEngineeringStrategy(or.getReverseEngineeringStrategy(new DefaultReverseEngineeringStrategy()));
                cfg.readFromJDBC();
            } catch (Exception e) {
                Exceptions.printStackTrace(e);
            }

            // Generating POJOs
            FileObject pkg;
            try {
                pkg = SourceGroups.getFolderForPackage(helper.getLocation(), helper.getPackageName());
                File outputDir = FileUtil.toFile(pkg);
                POJOExporter exporter = new POJOExporter(cfg, outputDir);
                exporter.getProperties().setProperty("jdk", new Boolean(helper.getJavaSyntax()).toString());
                exporter.getProperties().setProperty("ejb3", new Boolean(helper.getEjbAnnotation()).toString());
                exporter.start();
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }

            // Generate Mappings
            try {
                pkg = SourceGroups.getFolderForPackage(helper.getLocation(), helper.getPackageName());               
                File outputDir = FileUtil.toFile(pkg);
                HibernateMappingExporter exporter = new HibernateMappingExporter(cfg, outputDir);               
                exporter.start();
            } catch (Exception e) {
                Exceptions.printStackTrace(ex);
            }

in the code outputDir is
C:\Documents and Settings\gowri\MyDocuments\NetBeansProjects\WebApplication57\src\java\Travel.

But the generated pojo and mapping files don't contain package as Travel .

// default package
// Generated May 27, 2008 12:45:56 AM by Hibernate Tools 3.2.1.GA


import java.util.Date;

/**
 * Person generated by hbm2java
 */
public class Person  implements java.io.Serializable {


     private int personid;
     private String name;
     private String jobtitle;
     private Short frequentflyer;
     private Date lastupdated;

    public Person() {
    }

   
    public Person(int personid) {
        this.personid = personid;
    }
    public Person(int personid, String name, String jobtitle, Short frequentflyer, Date lastupdated) {
       this.personid = personid;
       this.name = name;
       this.jobtitle = jobtitle;
       this.frequentflyer = frequentflyer;
       this.lastupdated = lastupdated;
    }


<?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 May 27, 2008 12:45:57 AM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>

<class name="Person" table="PERSON" schema="TRAVEL">
    <id  name="personid" type="int">
   


class name should be Travel.Person.

Wondering why tools is not setting the package right ?

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