我有一个贷款表和一个相册表,该表已连接到一个ManytoMany关系。
我正在尝试创建一个查询,以根据专辑被借出的次数列出最受欢迎的专辑。
贷款类:
@Entity
public class Loan implements Serializable {
private static final long serialVersionUID = 0x62B6DA99AA12AAA8L;
@Column @GeneratedValue(strategy = GenerationType.AUTO) @Id private Integer id;
@ManyToMany(fetch = FetchType.LAZY)
private List<Album> album;
@Column private String dateLoaned;
@Column private String dateToReturn;
@Column private String dateReturned;
@Column private Boolean active=false;
相册类:
@Entity
public class Album implements Serializable {
private static final long serialVersionUID = 0x63A6DA99AA12AAA8L;
@Column @GeneratedValue(strategy = GenerationType.AUTO) @Id private Integer id;
@Column (unique=true) private String barcode;
@Column private String band;
@Column private String title;
@Column private String genre;
@Column private Integer year;
@Column private String artworkFilename;
@Column private Boolean enabled;
@Column private Boolean isLoanable;
@Column private Integer numberOfCopies;
@ManyToMany()
private List<Loan> loan;
在我的相册存储库中,我一直试图构造一个查询来执行此操作,但是它不起作用。
@Query(" ")
List<Album> getPopularAlbums();
我尝试使用“ select from from album_loan where 1” 类型的东西创建一个简单查询,但总是收到_“ album_loan not mapping” _错误。