我有两个表,书和作者是多对多的关系
book.java
@Id
@GeneratedValue
private Integer id;
@ManyToMany
@JoinTable(name="BookAuthor",
joinColumns=@JoinColumn(name="id"),
inverseJoinColumns=@JoinColumn(name="author_id"))
private List<Author> authors;
Author.java
@Id
@GeneratedValue
private Integer id;
@ManyToMany(mappedBy = "authors")
private List<Book> books;
我现在正在尝试在查询中加入两个表
String hql = "select book from Book book" +
" join book.authors author where author.id = :author_id";
但是我收到了这些错误
Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token:
我在book.java中命名连接ID是错误的,还是在查询中命名错误?