[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3458) Register postgres random() function as "rand" in PostgresSQLDialect

Grep Sed (JIRA) noreply at atlassian.com
Thu Mar 29 23:42:48 EDT 2012


    [ https://hibernate.onjira.com/browse/HHH-3458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46127#comment-46127 ] 

Grep Sed commented on HHH-3458:
-------------------------------

I'm surprised that this simple bug hasn't got fixed after 3.5 years.

> Register postgres random() function as "rand" in PostgresSQLDialect
> -------------------------------------------------------------------
>
>                 Key: HHH-3458
>                 URL: https://hibernate.onjira.com/browse/HHH-3458
>             Project: Hibernate ORM
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 3.2.5
>         Environment: Postgres 8.3
>            Reporter: Stephen Cresswell
>            Priority: Trivial
>
> I have an HQL query which uses "order by rand()". This works fine in our local integration tests (which are run against hsqldb), but fails against our build integration tests which runs postgres.
> The reason the query fails is because postgres function for "rand" is called "random". We can workaround this by dynamically detecting the db driver and generating db specific queries, but it strikes me that the cleanest solution for this is to simply re-register postgres' random function as "rand" in the PostgresSQLDialect, i.e.
>         registerFunction( "random", new NoArgSQLFunction("random", Hibernate.DOUBLE) );
>         registerFunction( "rand", new NoArgSQLFunction("random", Hibernate.DOUBLE) );

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list