• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

listing hibernate named queries from java

 
Ronan Dowd
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • 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>
 
Aditya Keyal
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • 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.



 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the ORM forum, this is a Hibernate question.

Thanks

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic