我的类名是
批处理作业
我的表名是
batch_jobs
我正在使用 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 is not 映射 [来自批处理作业]
我的查询
allBatchJobs=session.createQuery("From BatchJob").list();
我的休眠.cfg.xml映射
<mapping class="com.company.bmdashboard.beans.BatchJob"></mapping>
当我将类名更改为batch_jobs时,代码工作正常,但我想使用名称 BatchJob 并且我不想使用 javax.persistence 类。
请指导我。提前致谢
试试这个....
import javax.persistence.Entity;
import org.hibernate.annotations.Table;
@Entity
@Table(name="batch_jobs")
public class BatchJob {
请使用javax.persistence包,如下所示
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@org.hibernate.annotations.Table
使用来自javax.persistence.Table;
和/或javax.persistence.SecondaryTables;
的值。举个例子:
@Table(name = "batch_jobs")
@SecondaryTables({
@SecondaryTable(name="batch")
})
@Entity
@org.hibernate.annotations.Table(inverse = true, appliesTo = "batch")
public class BatchJob {
所以,@org.hibernate.annotations.Table
不等于javax.persistence.Table;
,这是具有不同目的的不同注释。