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

Stephen Cresswell (JIRA) noreply at atlassian.com
Mon Sep 1 03:38:13 EDT 2008


Register postgres random() function as "rand" in PostgresSQLDialect
-------------------------------------------------------------------

                 Key: HHH-3458
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3458
             Project: Hibernate3
          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.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list