0

I need to run a query that uses a function I created on the Oracle SQL(10g) database.

  • I've seen that Hibernate supports some aggregate functions (avg, sum, min, max and some forms of count) but I want my own function so this doesn't work.

  • I have also seen that I can use SQLQuery object for direct sql injection. But here I loose pagination and I really need this.

    Anyone knows how to do this? Thanks in advance!

kotoko
  • 3
  • 2
  • 1
    I now saw this question -> [link](http://stackoverflow.com/questions/1909315/how-can-you-call-custom-database-functions-with-hibernate). Is there really no way to use hql or criteria? – kotoko Apr 14 '11 at 08:35

1 Answers1

0

For HQL queries, you need to create your own dialect based on the Oracle dialect you're currently using (Oracle10gDialect), and add your function to this dialect.

For Criteria queries, you may define your own Criterion implementation and use it in your query. This Criterion is responsible of the generation of the SQL expression. Look at the Hibernate sources to find an example of an existing criterion implementation similar to the one you want to create.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255