如何解决JPQL 查询错误:方法查询验证失败
我有实体:
@Entity
public class Battle {
@SequenceGenerator(name = "battle_sequence",sequenceName = "battle_sequence",allocationSize = 1)
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "battle_sequence")
@Column(name = "id",updatable = false)
private long id;
private String title;
@Enumerated(EnumType.STRING)
private BattleLevel difficulty;
@Enumerated(EnumType.STRING)
private Language language;
private String prompt;
@OnetoMany(mappedBy = "battle",cascade=CascadeType.ALL)
private List<Solution> solutions = new ArrayList<Solution>();
@ManyToOne
@JoinColumn(nullable = false,name = "app_user_battle_id")
private AppUser appUser;
和
@Entity
public class Solution {
@SequenceGenerator(name = "solution_sequence",sequenceName = "solution_sequence",generator = "solution_sequence")
@Column(name = "id",updatable = false)
private long id;
private String name;
private String solution;
@ManyToOne
@JoinColumn(name = "battle_solution_id")
private Battle battle;
@ManyToOne
@JoinColumn(name = "app_user_solution_id")
private AppUser appUser;
我使用的是 JpaRepository 接口:
@Repository
public interface BattleRepository extends JpaRepository<Battle,Long>{
@Query("select b from Battle b where b.app_user_battle_id = :appUserId")
List<Battle> findAllByAppUserId(long appUserId);
出于某种原因, findAllByAppUserId 查询引发了验证失败错误。我不确定它到底有什么问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。