1 java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Student is not mapped [from Student] 2 at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:133) 3 at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157) 4 at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:164) 5 at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:670) 6 at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:686) 7 at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:103) 8 at com.tao.test.StudentTest.testAll(StudentTest.java:39) 9 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 10 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 11 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 12 at java.lang.reflect.Method.invoke(Method.java:498) 13 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) 14 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 15 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) 16 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) 17 at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) 18 at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) 19 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) 20 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) 21 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) 22 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) 23 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 24 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 25 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 26 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) 27 at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 28 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) 29 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 30 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) 31 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) 32 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) 33 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) 34 Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: Student is not mapped [from Student] 35 at org.hibernate.hql.internal.ast.QuerySyntaxException.generateQueryException(QuerySyntaxException.java:79) 36 at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:103) 37 at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:217) 38 at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:141) 39 at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115) 40 at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:77) 41 at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:153) 42 at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:553) 43 at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:662) 44 ... 28 more 45 Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: Student is not mapped 46 at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:171) 47 at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:91) 48 at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:79) 49 at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:324) 50 at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3696) 51 at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3585) 52 at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:720) 53 at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:576) 54 at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:313) 55 at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:261) 56 at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:266) 57 at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:189) 58 ... 34 more 59 60 org.hibernate.TransactionException: Transaction was marked for rollback only; cannot commit 61 at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:228) 62 at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:68) 63 at com.tao.test.StudentTest.testAfter(StudentTest.java:32) 64 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 65 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 66 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 67 at java.lang.reflect.Method.invoke(Method.java:498) 68 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) 69 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 70 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) 71 at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33) 72 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) 73 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) 74 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) 75 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) 76 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 77 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 78 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 79 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) 80 at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 81 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) 82 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 83 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) 84 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) 85 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) 86 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
我的报这个的错是因为
<property name="com/tao/pojo/Student.hbm.xml"></property>
<property name="com/tao/pojo/Clazz.hbm.xml"></property>
换成就OK了
<mapping resource="com/tao/pojo/Student.hbm.xml"/>
<mapping resource="com/tao/pojo/Clazz.hbm.xml"/>
第一行末尾就说的很明显:Student is not mapped (Student没有映射),所以从映射文件着手找就比较省时间了
转载于:https://www.cnblogs.com/jili6254/p/8195611.html