-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Externalise XML Queries with persistence annotations?
PostPosted: Mon Apr 05, 2010 9:42 am 
Newbie

Joined: Sun Jul 10, 2005 10:20 am
Posts: 17
Location: London
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.