mercredi 4 mai 2016

Hibernate unit test blocks on an insert statement

We are currently facing an issue with hibernate unit testing. Using Hibernate + JPA + Spring + junit + Maven + below is the persistence configuration:

<persistence-unit name="localContainerEntityForTest">
    <description>Spring JPA LocalContainerEntityManagerFactoryBean</description>
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <properties>
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
        <property name="hibernate.hbm2ddl.auto" value="create"/>
        <property name="hibernate.implicit_naming_strategy" value="legacy-jpa"/>
        <property name="hibernate.show_sql" value="true" />
        <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
        <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/ourServerApp?createDatabaseIfNotExist=true"/>
        <property name="javax.persistence.jdbc.user" value="hibernate"/>
        <property name="javax.persistence.jdbc.password" value="password"/>
    </properties>
</persistence-unit>

One of the developers created an unit-test and hibernate simply blocks at one insert statement. No errors, no logs, except the following in console:

Hibernate: insert into role (details, name) values (?, ?)
Hibernate: insert into permission (details, name, state) values (?, ?, ?)
Hibernate: insert into role_permission (permission_id, role_id) values (?, ?)

Blocks at the last one. On the author's machine (the one who created the unit test) all is well and working, unit test passing. But on other developer machines the test simply blocks at this statement. We are not able to find out why this happens. It seems that this is a database lock issue, but not sure.

Why this might happen and how we can figure out what's wrong?

P.S. Same MySQL version, tomcat, source up to date.

Aucun commentaire:

Enregistrer un commentaire