gpt4 book ai didi

java - Hibernate 查询语法异常

转载 作者:行者123 更新时间:2023-12-02 00:24:34 25 4
gpt4 key购买 nike

我有两个名为 Batch 和 Position 的类,并且遇到此错误

由以下原因引起:org.hibernate.hql.ast.QuerySyntaxException:子树意外结束[来自 bean.Position p,其中:p.positionConstraint 的批处理成员]

当调用findByStudent方法时。我也在使用 JPA,如果有帮助的话。非常感谢

public  class  Position {  
@ElementCollection
@LazyCollection(LazyCollectionOption.FALSE)
@CollectionTable(name = "position_constraint")
private List<Batch> positionConstraint;
}


public class Batch {
private College college;

private YearLevel yearLevel;

@Override
public List<Position> findByStudent(StudentInformation student) {
Batch batch = new Batch(student.getCollege(), student.getYearLevel());

Query query = getEntityManager().createQuery(
"from Position p where :batch member of p.positionConstraint").setParameter("batch", batch);
return query.getResultList();
}

最佳答案

我认为您的字符串有错误。它应该是:“来自位置p,其中:p.positionConstraint的batch成员”

关于java - Hibernate 查询语法异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10279240/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com