我有一個(gè)使用Hibernate的項(xiàng)目,但有一個(gè)錯(cuò)誤表未映射。org.jboss.resteasy.spi.UnhandledException: javax.ejb.EJBException: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: TrainingRoom is not mapped [SELECT DISTINCT t FROM TrainingRoom t ORDER BY t.id]at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:77)at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:220)at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:175)...Caused by: javax.ejb.EJBException: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: TrainingRoom is not mapped [SELECT DISTINCT t FROM TrainingRoom t ORDER BY t.id]at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:187)at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:277)at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:327)...Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: TrainingRoom is not mapped [SELECT DISTINCT t FROM TrainingRoom t ORDER BY t.id]at org.hibernate.hql.internal.ast.QuerySyntaxException.generateQueryException(QuerySyntaxException.java:79)at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:103)at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:218)...這是我的TrainingRoom.java@Entity@Table(name = "ppp_trainingRoom")public class TrainingRoom { @Id @GeneratedValue(strategy = GenerationType.TABLE) @Column(name = "id", updatable = false, nullable = false) private Long id; @Column private String roomName; //GET SET Method}在遇到這個(gè)錯(cuò)誤之前,我有2個(gè)EntityManager,因?yàn)槲矣幸恍┩x詞表。但是我發(fā)現(xiàn)它不是必須的。所以我刪除了它,然后卡住了,就像上面的錯(cuò)誤一樣。我該如何解決?
1 回答

有只小跳蛙
TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超8個(gè)贊
您可以添加新屬性:
<property name="hibernate.archive.autodetection" value="class" />
或者,您可以在持久性單元標(biāo)簽下為每個(gè)類(lèi)指定類(lèi)標(biāo)簽:
<class>org.cmh.itsetup.model.TrainingRoom</class>
添加回答
舉報(bào)
0/150
提交
取消