Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with ROUND function on H2 database

PaulN Pearson
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has anyone come across the following problem in JPA/Hibernate/Spring:

I have a persisted instance of a class MyClass which contains a Float instance variable, f, mapped to a database FLOAT type (either Oracle or H2). The value of f is 123.456.

I execute the following code:

Which prints "1" when run with an Oracle database (which is what I would expect), but "0" with H2.

What's more, on H2, when I remove the ROUND function and just query on "myClass.f = ?1" I get one result as expected, which suggests ROUND is the problem. But also when I leave ROUND there, and hardcode the parameter ?1 as "123.456" I also get one result, which suggests it's the setting of the parameter that's the problem!!!

Can anyone enlighten me as to what's going wrong here?
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!