我有2
桌子。1st
一个有oneToMany
关系2nd
。
班级作者
@Entity
@Table(name = "Author")
Public class Author{
@Id
@Column(name = "AuthorId")
private int autherId;
@Column(name = "AuthorName")
private String authorName;
@OneToMany
@JoinColumn(name="AuthorId",referencedColumnName="AuthorId")
List<Book> Books;
//getter and setter
}
课本
@Entity
@Table(name = "Book")
Public class Book{
@Id
@Column(name = "BookId")
private int bookId;
@Column(name = "BookName")
private String bookName;
@Column(name = "AuthorId")
private int authorId;
//getter and setter
}
如何编写Hql
查询,以便获得所有作者和那里的书籍,条件是书名应以hello
我知道使用这样的查询,
from Author;
我可以获取所有作者和那里的书,但是如何给书提供条件?