gpt4 book ai didi

java - 尽管实体已绑定(bind),但什么会导致 QuerySyntaxException : [Entity] is not mapped,?

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:51:32 25 4
gpt4 key购买 nike

我想知道为什么我得到 QuerySyntaxException: [Entity] is not mapped,尽管 Hibernate 正在记录

INFO Hibernate EntityManager 3.5.0-Final
...
INFO Binding entity from annotated class: products.model.ProductGroup
INFO Bind entity products.model.ProductGroup on table GRP
...
INFO table found: GRP
INFO columns: [grp, name, top]

实体类看起来像

@Entity(name="GRP")
public class ProductGroup implements IdentifiableEntity {

@Id
private String grp;
private String name;
private String top;

...
}

错误在这一行抛出:

Query q = em.createQuery("select g from ProductGroup g");

全是 JPA,没有 Hibernate API。

最佳答案

@Entity(name) 设置 JPA 实体的内部名称。尝试删除该语句并使用 @Table(name = "GRP")

如果这不起作用,请发布完整的堆栈跟踪。

关于java - 尽管实体已绑定(bind),但什么会导致 QuerySyntaxException : [Entity] is not mapped,?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11952694/

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