-->
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: problem/question: getNamedQuery + non-managed entity
PostPosted: Thu Jun 17, 2010 10:25 am 
Newbie

Joined: Thu Jun 17, 2010 9:42 am
Posts: 1
Hi,

I need to do some complex SQL for report app.
Is it possible to use "getNamedQuery" method to avoid write long SQLs on source code?
I would to do something like the following code:

Code:
List<Company> result = getSession().getNamedQuery("findCompaniesByCode")
   .setResultTransformer(new AliasToBeanResultTransformer(Company.class))
   .list();


where Company is a simple pojo (without any annotation/mapping).
Then query "findCompaniesByCode" would be placed in a .xml file and loaded by sessionFactory.

My application-context.xml has the following configuration:

Code:
   <bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
      p:dataSource-ref="dataSource">
      <property name="mappingLocations">
         <list>
            <value>classpath:*.xml</value>
         </list>
      </property>
      <property name="hibernateProperties">
         <props>
            <prop key="hibernate.dialect"> ${hibernate.db.dialect} </prop>
         </props>
      </property>
   </bean>


Does it make sense? Is it possible?
Or namedQuery works only for entity managed by Hibernate?

Any suggestion?

Thanks in advance.
Best,
Rodrigo


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.