Interestingly enough this query produces exactly the kind of result you’d expect when multiplying 2f with 2.5d:
The query is update test_entity set int_field=(cast(? as float(24))*cast(? as float(53))) which seems perfectly correct to me, as far as parameter types go. It truncates the result but if that’s not intended it is user error, the framework does what it was asked. But honestly I don’t have a strong opinion on if narrowing should produce an exception or truncate. On the other hand I feel that the parameter types should be correct either way. Or, let me put it this way: Hibernate can resolve the param types correctly when no additional information is given. But give Hibernate more information by adding a known entity field to the calculation and suddenly parameter types are expected to be different to what they actually are. Yet from the outside it seems it should be easier to get the types right if Hibernate has more info available. That is why it tripped up my expectation of what would happen. |