• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

listing hibernate named queries from java

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I'd like to write a JUnit test which executes all named queries which I've defined in my application. My named queries
are present in a few separate hibernate mapping files (sample below).

Is there a way in spring (v2.5.1 am using) perhaps of, from Java, getting a list of all named queries defined in my "hbm.xml" files ?

<sql-query name="getAllCustomer">
select name from Customer
</sql-query>

<sql-query name="getAllAccounts">
select name from Account
</sql-query>

Alternatively I could write some parsing code that would search for "<sql-query name=" in all "hbm.xml" files and extract
the name of the query but I reckon spring must have some bean to do this?

Any help would be great.
Thanks, Ro>
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ronan,

AFAIK spring does not really provide you any facility to scan/parse/assimilate data present in hbm.xml files since they are a part of Hibernate and not really Spring. If you were populating a map with all the named queries or calling the named queries by setting their values in a bean then it was a different scenario and could be tackled by way of Spring.



 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the ORM forum, this is a Hibernate question.

Thanks

Mark
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic