开发者

How to use in hibernate user-defined-function done is sql (and still have pagination)

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 advan开发者_如何学Cce!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜