[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5251) NativeSQLQueryReturn impls pre-cache a final hashcode based on non-final fields
Gail Badner (JIRA)
noreply at atlassian.com
Sun Jun 13 18:21:58 EDT 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5251?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37436#action_37436 ]
Gail Badner commented on HHH-5251:
----------------------------------
Fixed in trunk and Branch_3_5.
> 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.x, 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