我试图使用CriteriaBuilder和元模型来联接表。 但是看来我做错了。
//this is where is get and join tables
Root<Album> mainTable = criteria.from(Album.class);
Join<Album, Track> tracksJoin = mainTable.join(Track_.album, JoinType.INNER); //type conflict
//piece of metamodel 1
@StaticMetamodel(Album.class)
public class Album_ {
public static volatile CollectionAttribute<Album, Track> tracksList;
//piece of metamodel 2
@StaticMetamodel(Track.class)
public class Track_ {
public static volatile SingularAttribute<Track, Album> album;
//piece of DAO Album
@ManyToMany
private ArrayList<Track> tracksList;
//piece of DAO Track
private Album album;
能否请您解释我在做什么错以及如何加入这些表格。
答案 0 :(得分:0)
尝试一下,在类似的情况下,我的代码成功了。
Join<Album, Track> tracksJoin = mainTable.join(ALBUM_.tracksList, JoinType.INNER).join(Track_.album, JoinType.INNER);