Forums Register Login

listing hibernate named queries from java

+Pie Number of slices to send: Send
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>
+Pie Number of slices to send: Send
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.



+Pie Number of slices to send: Send
Moving this to the ORM forum, this is a Hibernate question.

Thanks

Mark
You have to be odd to be #1 - Seuss. An odd little ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1748 times.
Similar Threads
SQL-Query not returning specified Object
@NamedQuery - Where it should be
Searching for files of a specific type in jdk1.4
Hibernate in a DAO pattern & lazy loading
trouble using BINARY in where clause with Hibernate 3.1
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 03:45:35.