0

With Hibernate 5.6.5.Final, I try to create a simple ManyToMany relation between those entities:

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

@Entity
@Table(name = "book")
public class BookEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToMany(targetEntity = AuthorEntity.class)
    @JoinTable(name = "book_author")
    private Set<AuthorEntity> authors = new HashSet<>();
}

@Entity
@Table(name = "author")
public class AuthorEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToMany(targetEntity = AuthorEntity.class, mappedBy = "authors")
    private Set<BookEntity> books = new HashSet<>();
}

In pom.xml, I only have this hibernate dependency: hibernate-entitymanager

When I run the program, I get this error:

java.lang.NoSuchMethodError: 'javax.persistence.Index[] javax.persistence.JoinTable.indexes()'

Does anybody have any idea what might have gone wrong?

  • Note 1: if I remove @Table, I get a similar error about @JoinTable.
  • Note 2: I do not use Spring
Mark Rotteveel
  • 90,369
  • 161
  • 124
  • 175
user3429660
  • 1,853
  • 3
  • 18
  • 34

0 Answers0