【发布时间】:2019-03-19 18:36:16
【问题描述】:
我的班级名称是
批量作业
我的表名是
批处理作业
我正在使用 org.hibernate.annotations.Table 类的 @Table 而不是 javax.persistence
我的 BatchJob 类代码是
import javax.persistence.Entity;
import org.hibernate.annotations.Table;
@Entity
@Table(appliesTo="batch_jobs")
public class BatchJob {
我遇到错误
org.hibernate.AnnotationException: @org.hibernate.annotations.Table 引用未知表:batch_jobs
当我将 @Entity 表示法的类更改为 org.hibernate.annotations
import org.hibernate.annotations.Entity;
import org.hibernate.annotations.Table;
@Entity
@Table(appliesTo="batch_jobs")
public class BatchJob {
我遇到错误
org.hibernate.hql.internal.ast.QuerySyntaxException: BatchJob 不是 映射 [来自 BatchJob]
我的查询
allBatchJobs=session.createQuery("From BatchJob").list();
我的 hibernate.cfg.xml 映射
<mapping class="com.company.bmdashboard.beans.BatchJob"></mapping>
当我将我的类名更改为 batch_jobs 时,代码工作正常,但我想使用名称 BatchJob 而我不想使用 javax.persistence 类。
请指导我。提前致谢
【问题讨论】:
-
您使用的是哪个版本的 Hibernate?可能与以下问题有关HHH-10913
-
我正在使用 4.3.11 。我阅读了您提供的链接,但没有给我任何解决方案。你有什么想法吗?
-
从那个问题看来,在我看来,您的要求是不可行的,因为 applyTo 属性必须引用 已经存在 表,它不打算声明名称像你一样的桌子。
标签: java xml spring hibernate annotations