Hi all,
I'm using Hibernate 3 annotations to persist the domain model. However I'd like to externalise Queries in a hibernate XML file. I'm using strict Hibernate (e.g. no JPA configuration with META-INF/persistence.xml). If you want to consider the following (I know we are in a Hibernate forum), I'm using Spring 2.5 to declare the SessionFactory as follows (but you may avoid answering about Spring if you don't know/want since it's not actually essential for the answer to this post):
Code:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="packagesToScan" value="uk.co.jemos.experiments.persistence.domain"></property>
<property name="annotatedPackages" value="uk.co.jemos.experiments.persistence.types" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.use_sql_comments">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
</props>
</property>
<property name="dataSource" ref="jemosDataSource" />
</bean>
Everything works fine. I could declare Queries in @NamedQueries annotations at the package level (package-info.html), but I'd like to have the possibility to use some high level Hibernate XML file where to declare Queries (and other general options) and this file should co-exist with the Annotation configuration. Any suggestion?
Thanks in advance,
M.