I would like to use the <mapping package="..."> tag to find my annotated classes instead of the more explicit <mapping class="..">. But when I use the mapping package tag, it doesn't find my entities.
hibernate version
using hibernate annotations version 3.1 beta 6 with hibernate 3.1 rc1 and hibernate tools 3.0.0 alpha 4a
mapping files
Here is my ant task I am running:
Code:
<target name="db-gen-create-sql" depends="compile,create-hibernate-cfg,copy-generated-resources" description="creates ddl schema file from hibernate files">
<echo message="creating table schema in ${build.dir} with the name of 'create-tables.sql'"/>
<hibernatetool destdir="${build.dir}" >
<annotationconfiguration configurationfile="${hibernate.config.file}" />
<hbm2ddl export="true" console="false" drop="false" create="true"
outputfilename="${project.name}-create.ddl" delimiter=";"/>
</hibernatetool>
</target>
Here is the configuration that DOESNT work
Code:
<?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>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:iesdevl</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
<property name="hibernate.connection.username">xxxx</property>
<property name="hibernate.connection.password">xxxx</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.default_schema">dbridge</property>
<mapping package="edu.uwec.lts.adminservices"/>
</session-factory>
</hibernate-configuration>
Only difference to make it work is to use <mapping class> instead
Code:
<mapping class="edu.uwec.lts.adminservices.model.TestEntity"/>
when I use the mapping package tag, the ant task processes normally, but no schema is generated. When I use the <mapping class> tag the schema is generated. It seems to be ignoring the <mapping package> tag altogether.
off topic:
I am also trying to instantiate a hibernate session using an IoC framework (Spring) and passing in package names vs. explicit class references there too, and same problem occurs. I can show this code if you like, too.