Hibernate Tools version: 3.2.4.Alpha1
Hi,
I have spent two days setting up the Hibernate Tools for my project and I still cannot get the named queries to be in the DAO object.
- I have a User.hbm.xml generated from the DB and the reveng.xml file.
- I have declared the named query in a separate UserQueries.hbm.xml file with the fully qualified class name as prefix.
Code:
<query name="cls.argodata.common.hibernate.pojo.User.findByLastName"><![CDATA[
from User as user where user.lastName = :lastName
]]>
<query-param name="lastName" type="string" />
</query>
- These two hbm.xml files are included in the configuration mappings.
Code:
<mapping resource="cls/argodata/common/hibernate/pojo/User.hbm.xml" />
<mapping resource="cls/argodata/common/hibernate/pojo/UserQueries.hbm.xml" />
- I have a custom template file that is basically a copy of the provided one except for the logger variable that I have changed.
It seems that in that template file, the cfg.namedQueries.keySet() does not return anything: The foreach is not executed once.
However, when I try programmatically with the same files, I can execute that named query.
Any idea why the named query is not being included in the set?
PS: my hibernate.cfg.xml :
Code:
<hibernate-configuration>
<session-factory name="sf">
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/xxx</property>
<property name="hibernate.connection.username">xxx</property>
<property name="hibernate.connection.password">xxx</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Mapping declarations -->
<mapping resource="cls/argodata/common/hibernate/pojo/Sensor.hbm.xml" />
<mapping resource="cls/argodata/common/hibernate/pojo/Beacon.hbm.xml" />
<mapping resource="cls/argodata/common/hibernate/pojo/Device.hbm.xml" />
<mapping resource="cls/argodata/common/hibernate/pojo/Unit.hbm.xml" />
<mapping resource="cls/argodata/common/hibernate/pojo/User.hbm.xml" />
<mapping resource="cls/argodata/common/hibernate/pojo/UserQueries.hbm.xml" />
</session-factory>
</hibernate-configuration>