我正在使用此查询:
SELECT rank FROM
(SELECT @rank:=@rank+1 AS rank, score_id From Model_Score where model_id = ? ORDER BY score_id )
AS X JOIN (SELECT @rank := 0)
AS Y where X.score_id = ?
我需要获得与条件模型和分数匹配的元素行。
在我的java课程中,我使用了这个:
return getJdbcTemplate().queryForObject(sqlCommand, new Object[] {model_id, score_id}, Integer.class);
但它会生成一个零点异常。有可能" @ rank"令牌是主要原因吗?
感谢, 安德烈
- Stacktrace
02:17:38,793 PM CEST ERROR ModelDaoMySql @ getLevelOfRecommendation [456] Unable to getLevelOfRecommendation(model: 10, score_id: 17) - java.lang.NullPointerException
java.lang.NullPointerException
at com.mediresource.datatype.model.database.mysql.ModelDaoMySql.getLevelOfRecommendation(ModelDaoMySql.java:437)
at com.mediresource.datatype.question.PEAQFactory.getPeaqModels(PEAQFactory.java:442)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.mediresource.container.BOContentFactory.callReflectionGetContent(BOContentFactory.java:888)
at com.mediresource.container.BOContentFactory.generateWidget(BOContentFactory.java:496)
at com.mediresource.container.BOContentFactory.fillContent(BOContentFactory.java:458)
at com.mediresource.container.BOContentFactory.getBOContent(BOContentFactory.java:387)
at com.mediresource.container.BOContentFactory.getBOContent(BOContentFactory.java:410)
at com.mediresource.container.BOContentFactory.getBOContent(BOContentFactory.java:410)
at com.mediresource.container.BOContentFactory.getBOContent(BOContentFactory.java:261)
at com.mediresource.test.application.ManulifePEAQ.test_PEAQ(ManulifePEAQ.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:232)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:175)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)