[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5273?page=c...
]
Steve Ebersole closed HHH-5273.
-------------------------------
Assignee: Steve Ebersole
Resolution: Rejected
HHH-5138 has no bearing on this report.
The return types for criteria aggregations were changed as part of HHH-1724.
The point is that prior to 3.5 criteria handle aggregation function return values
differently from all other parts of Hibernate. The change in 3.5 was to align them with
the rest of the usage.
If you wish to remain with the older return types, register the "classic"
derivations of these functions with the dialect or function registry. However, note that
the return types are consistent now and this will effect all usages of these functions
(criteria, hql, etc).
RowCountProjection long to int cast exception
---------------------------------------------
Key: HHH-5273
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5273
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.5.2
Environment: hibernate-core 3.5.2
Reporter: Pamir Erdem
Assignee: Steve Ebersole
After we upgraded our hibernate.jar from 3.3.2 to 3.5.2 the methods which executes
rowcount functions have started to throw long to cast exception.
From the source code of hibernate, it is clear that for the features which will be
implemented in 3.6
some implementations are changed.
#http://opensource.atlassian.com/projects/hibernate/browse/HHH-5138
In 3.3.2
{code:title=RowCountProjection.java|borderStyle=solid}
public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
return new Type[] { Hibernate.INTEGER };
}
{code}
In 3.5.2
{code:title=RowCountProjection.java|borderStyle=solid}
return new Type[] {
getFunction( criteriaQuery ).getReturnType( null, criteriaQuery.getFactory() )
};
{code}
But the definitions of the rowcount functions in both versions in same in Dialect.java
{code}
static {
STANDARD_AGGREGATE_FUNCTIONS.put(
"count",
new StandardSQLFunction("count") {
public Type getReturnType(Type columnType, Mapping mapping) {
return Hibernate.LONG;
}
public String render(List args, SessionFactoryImplementor factory) {
if ( args.size() > 1 ) {
if ( "distinct".equalsIgnoreCase( args.get( 0 ).toString() ) ) {
return renderCountDistinct( args );
}
}
return super.render( args, factory );
}
{code}
By this minor change in 3.5.2 all the project tests which executes count sql function are
failing by throwing class cast exception
--
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