[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5212) Alter SQLFunction contract to be more flexible

Fred Toussi (JIRA) noreply at atlassian.com
Thu Jul 8 12:22:14 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37673#action_37673 ] 

Fred Toussi commented on HHH-5212:
----------------------------------

It is a good idea to add deprecation now to give dialect developers time to support the new approach.
Re the proposed interface, please consider the following:
Some SQL functions can appear both with and without parentheses when there is no argument.I am not proposing a change to the interface as in practice it may not be necessary to use both forms.

Usually this comes up when the RDBMS supports functions from several non-standard dialects of SQL. For example functions TIMESTAMP(A) and TIMESTAMP(A, B) where A and B are either string or date/time look similar to the type definition TIMESTAMP(n) where n is a number. Or functions TODAY and TODAY(). HSQLDB 2.0 has some examples of multiple formats.





> Alter SQLFunction contract to be more flexible
> ----------------------------------------------
>
>                 Key: HHH-5212
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5212
>             Project: Hibernate Core
>          Issue Type: Improvement
>          Components: core, query-criteria, query-hql
>            Reporter: Steve Ebersole
>
> The SQLFunction contract currently combines contextual information (render/getReturnType) and non-contextual (aka non-changing) information (hasArguments/hasParenthesesIfNoArguments).
> An example I just ran into where separating these would have been nice is in HHH-5173.  Some dialects return the argument data type when applying the AVG() function.  That is problematic for INTEGER values because the decimal portion gets dropped.  On those databases one would need to CAST() the argument to get the correct behavior.  However, again, this is only necessary based on the argument type.  If the argument type is already a non-integer the cast is uneeded.
> Proposal (as always name subject to change/suggestion):
> {code}
> interface SQLFunction {
>     public boolean hasArguments();
>     public boolean hasParenthesesIfNoArguments();
>     public RenderingContext getRenderingContext(Type columnType, SessionFactoryImplementor factory);
>     public static interface RenderingContext {
>         public Type getReturnType();
>         public String render(List args);
>     }
> }
> {code}
> I used SessionFactoryImplementor as the argument to getRenderingContext, but the current getReturnType accepts a Mapping.  Is there really ever a time when we call that method when we do not have a SessionFactory?  My usage search shows no usages of this method passing in a Configuration (which is the other Mapping implementor aside from SessionFactory).

-- 
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