No value specified for parameter when using MySQL with JPA/Hibernate

I came across a problem when swithching database for a project from HSQLDB to MySQL.

I am using memory based HSQL for unit tests.
I am using file based HSQL for development testing.
I have changed my integration tests to using MySQL from file based HSQL.
Final production release will probably use MySQL or Firebird.
(This isn't commercial work, so no Oracle in any stack...)

But when I switched to MySQL, JPA/Hibernate starting complaining about: No value specified for parameter 2. As usual the generic multiple vendor reasons for using JPA/JDBC usually is not true...

Was a bit dumbfounded with this error, but eventually found the solution : http://opensource.atlassian.com/projects/hibernate/browse/HHH-2605.

As it turns out there is a bug in the version of Hibernate that I use.

I depend on
 <dependencies>
 ...
   <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-   entitymanager</artifactId>
    <version>3.3.1.ga</version>
   </dependency>
 ...
 </dependencies>

And this version in the maven repositories was uploaded with wrong transparent dependency to hibernate 3.2.4.ga, which is buggy.

But the quick fix is to change my own dependency management to use version 3.2.6.

Thus this change solved the problem:
 <dependencyManagement>
 ...
   <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate</artifactId>
    <version>3.2.6.ga</version>
   </dependency>
 ...
 </dependencyManagement>

Maven causes problems, but also solves problems...

Comments

Comments below were made on a legacy Blog, before move to current Blog (February 2019)

Fernando:

I am new at maven. I would like to know why I should put the tag dependecyManagement instead of putting in build/dependency?

I don't know the differencies, but I dont have dependecyManagement.

Thanks in advance.

5 Mar 2009, 15:35:00
Creative Commons License

Unless otherwise specified, all content is licensed under Creative Commons by Attribution 3.0 (CC-BY).

Externally linked images and content are not included and are licensed and copyrighted separately.