我正在尝试在我的JPA存储库之一中选择内部联接
查询:
@Query(value = "select wm.WagerIdentification, wm.BoardNumber, wm.MarkSequenceNumber, wm.MarkNumber," + " pt.CouponTypeIdentification, pt.WagerBoardQuickPickMarksBoard " + "from WagerBoard wb " + "inner join wb.listOfWagerMarks wm on wb.WagerIdentification = wm.WagerIdentification and wb.BoardNumber = wm.BoardNumber and wb.GameIdentification = wm.GameIdentification and wm.meta_IsCurrent = 1 " + "inner join wb.poolgameTransaction pt on (wb.TransactionIdentification = pt.TransactionIdentification and pt.meta_IsCurrent = 1)" + "where wb.meta_IsCurrent = 1") List<Object[]> findAllTest();
关系:
池游戏交易
@OneToMany(mappedBy = "poolgameTransaction") private List<WagerBoard> ListOfWagers = new ArrayList<>();
赌板
@ManyToOne(fetch=FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "TransactionIdentification", insertable = false, updatable = false), @JoinColumn(name = "meta_CreatedDate", insertable = false, updatable = false) }) private PoolgameTransaction poolgameTransaction; @OneToMany(mappedBy = "wagerBoard") private List<WagerBoardMarks> listOfWagerMarks;
赌注标记
@ManyToOne(fetch=FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "BoardNumber", insertable = false, updatable = false), @JoinColumn(name = "GameIdentification", insertable = false, updatable = false), @JoinColumn(name = "WagerIdentification", insertable = false, updatable = false), @JoinColumn(name = "meta_CreatedDate", insertable = false, updatable = false) }) private WagerBoard wagerBoard;
错误:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: with-clause referenced two different from-clause elements
我将从On ..删除条件到where部分:
select wm.WagerIdentification, wm.BoardNumber, wm.MarkSequenceNumber, wm.MarkNumber," + " pt.CouponTypeIdentification, pt.WagerBoardQuickPickMarksBoard " + "from WagerBoard wb " + "inner join wb.listOfWagerMarks wm "inner join wb.poolgameTransaction pt where wm.meta_IsCurrent = 1 and wb.meta_IsCurrent = 1
无论如何,其他依赖项隐式嵌入在映射配置中。