CastFunctionTest. testFloatCasting and testLongCasting fail on mysql
Description
Activity
![](https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/default-avatar.png)
Former user June 26, 2014 at 12:04 AM
![](https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/default-avatar.png)
Former user June 18, 2014 at 11:18 PM
Tests are skipped when MySQLDialect or subclasses are used.
Pushed to 4.2 only.
![](https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/default-avatar.png)
Former user June 18, 2014 at 10:53 PMEdited
This was fixed as part of HHH-8454, which was not backported to 4.2.
This is not a regression. I'll skip these tests for MySQL in 4.2.
![](https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/default-avatar.png)
Former user June 18, 2014 at 9:43 PM
The failures do not reproduce in 4.3. Here the comparison of SQL generated for 4.2 vs 4.3:
HQL: select cast(e.theLostNumber as float) from org.hibernate.test.hql.CastFunctionTest$MyEntity e
4.2 SQL: select cast(castfuncti0_.theLostNumber as float) as col_0_0_ from MyEntity castfuncti0_
4.3 SQL: select cast(castfuncti0_.theLostNumber as decimal) as col_0_0_ from MyEntity castfuncti0_
HQL: select cast(e.theLostNumber as long) from org.hibernate.test.hql.CastFunctionTest$MyEntity e
4.2 SQL: select cast(castfuncti0_.theLostNumber as bigint) as col_0_0_ from MyEntity castfuncti0_
4.3 SQL: select cast(castfuncti0_.theLostNumber as signed) as col_0_0_ from MyEntity castfuncti0_
In 4.3, the targets are changed to valid types in the generated SQL.
![](https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/default-avatar.png)
Former user June 18, 2014 at 9:06 PMEdited
MySQL 5.5 does not support casting to all targets. According to [1], these are the targets that are supported:
CAST(expr AS type)
The CAST() function takes an expression of any type and produces a result value of a specified type, similar to CONVERT(). See the description of CONVERT() for more information.
CONVERT(expr,type), CONVERT(expr USING transcoding_name)
The CONVERT() and CAST() functions take an expression of any type and produce a result value of a specified type.
The type for the result can be one of the following values:
BINARY[(N)]
CHAR[(N)]
DATE
DATETIME
DECIMAL[(M[,D])]
SIGNED [INTEGER]
TIME
UNSIGNED [INTEGER]
[1] https://dev.mysql.com/doc/refman/5.5/en/cast-functions.html#function_convert
Bulk close issues fixed in 4.2.14