[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-5251) NativeSQLQueryReturn impls pre-cache a final hashcode based on non-final fields

Steve Ebersole (JIRA) noreply at atlassian.com
Fri Jul 16 15:32:17 EDT 2010


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5251?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Ebersole closed HHH-5251.
-------------------------------


> NativeSQLQueryReturn impls pre-cache a final hashcode based on non-final fields 
> --------------------------------------------------------------------------------
>
>                 Key: HHH-5251
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5251
>             Project: Hibernate Core
>          Issue Type: Improvement
>          Components: core
>            Reporter: Steve Ebersole
>            Assignee: Gail Badner
>             Fix For: 3.5.3, 3.6
>
>
> For example, code such as 
> {code}
> public class NativeSQLQueryScalarReturn implements NativeSQLQueryReturn {
>     private Type type;
>     private String columnAlias;
>     private final int hashCode;
>     public NativeSQLQueryScalarReturn(String alias, Type type) {
>         this.type = type;
>         this.columnAlias = alias;
>         this.hashCode = determineHashCode();
>     }
>     ...
>     private int determineHashCode() {
>         int result = type != null ? type.hashCode() : 0;
>         result = 31 * result + ( getClass().getName().hashCode() );
>         result = 31 * result + ( columnAlias != null ? columnAlias.hashCode() : 0 );
>         return result;
>     }
>     public int hashCode() {
>         return hashCode;
>     }
> }
> {code}
> should really read as such (for correctness):
> {code}
> public class NativeSQLQueryScalarReturn implements NativeSQLQueryReturn {
>     private final Type type;
>     private final String columnAlias;
>     private final int hashCode;
>     public NativeSQLQueryScalarReturn(String alias, Type type) {
>         this.type = type;
>         this.columnAlias = alias;
>         this.hashCode = determineHashCode();
>     }
>     ...
>     private int determineHashCode() {
>         int result = type != null ? type.hashCode() : 0;
>         result = 31 * result + ( getClass().getName().hashCode() );
>         result = 31 * result + ( columnAlias != null ? columnAlias.hashCode() : 0 );
>         return result;
>     }
>     public int hashCode() {
>         return hashCode;
>     }
> }
> {code}

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