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: Steve Ebersole
Fix For: 3.6, 3.5.x
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira