2

According to this article https://vladmihalcea.com/hibernate-and-uuid-identifiers/ I wanted to generate with hibernate UUID to my class. IntelliJ says that 'Cannot resolve 'GenericGenerator' '. It doesnt recognize the GenericGenerator import neither.

Entity.java:

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

import org.hibernate.annotations.GenericGenerator;

@MappedSuperclass
public abstract class Entity {
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    @Column(columnDefinition = "CHAR(32)")
    @Id
    protected String id;

    public BaseEntity() {
    }
}

I have these dependencies in my build.gradle:

compile group: 'javax.persistence', name: 'javax.persistence-api', version: '2.2'
runtime group: 'org.hibernate', name: 'hibernate-core', version: '5.4.9.Final'
Nikolai Shevchenko
  • 7,083
  • 8
  • 33
  • 42
zzsolt
  • 41
  • 6

2 Answers2

2

As the @GenericGenerator annotation is part of hibernate-core, I'd check if the dependency has been registered correctly in the IntelliJ module. Sometimes it helps to re-import the project via build.gradle. Also I'd change the dependency type from runtime to compile as the dependency is needed at compile time as well.

compile group: 'org.hibernate', name: 'hibernate-core', version: '5.4.9.Final'
ldz
  • 2,217
  • 16
  • 21
1

Try changing the scope to "compile" for 'org.hibernate' dependency:

compile group: 'org.hibernate', name: 'hibernate-core', version: '5.4.9.Final'

More info about Gradle scopes: Difference between compile and runtime configurations in Gradle

Petr Aleksandrov
  • 1,434
  • 9
  • 24