Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switching from version 4.3.11.Final to 5.0.1.Final causes compilation error

I am trying to upgrade my Hibernate version from

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.3.11.Final</version>
</dependency>

to

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>5.0.1.Final</version>
</dependency>

Unfortunately by compiling I get the following error.

TestDao.java:[5,25] cannot find symbol

[ERROR] symbol: class Transactional

[ERROR] location: package javax.transaction

I have been struggling with it for over an hour now.

I have tried adding package spring-tx but it did not help.

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-tx</artifactId>
    <version>4.2.1.RELEASE</version>
</dependency>

Did anyone face a similar issue?

like image 577
Jagger Avatar asked Sep 30 '15 18:09

Jagger


1 Answers

spring-tx gives you org.springframework.transaction.annotation.Transactional, but your error message clearly states that you're trying to apply javax.transaction.Transactional.

Searching for javax.transaction.Transactional on Central shows a number of candidates; either javax.transaction:javax.transaction-api:1.2 or javax:javaee-api:7.0 looks like a reasonable option.

It appears that the POM for Hibernate 4.3 did include a dependency on the JBoss-specific version of the javax.transaction package but that it was removed in Hibernate 5.0, presumably because it had been standardized and including a hard dependency on a specific package could result in problems at runtime.

like image 196
chrylis -cautiouslyoptimistic- Avatar answered Oct 01 '22 23:10

chrylis -cautiouslyoptimistic-