我收到「User.findById(user_id)」錯誤,但不是很頻繁,但有時候,我不知道爲什麼。什麼導致這個錯誤?play.exceptions.JavaExecutionException:要加載的ID是加載所必需的
注:我使用的打版1.2.3
感謝。
函數拋出異常;
public static void getMemberProfile(Long user _id){
User sessionUser = getUser();
User user = User.findById(user_id);
錯誤信息;
2012-02-12T13:06:42+00:00 app[web.1]:
2012-02-12T13:06:42+00:00 app[web.1]: Execution exception (In /app/controllers/UserApi.java around line 470)
2012-02-12T13:06:42+00:00 app[web.1]: IllegalArgumentException occured : id to load is required for loading
2012-02-12T13:06:42+00:00 app[web.1]:
2012-02-12T13:06:42+00:00 app[web.1]: play.exceptions.JavaExecutionException: id to load is required for loading
2012-02-12T13:06:42+00:00 app[web.1]: at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)
2012-02-12T13:06:42+00:00 app[web.1]: at Invocation.HTTP Request(Play!)
2012-02-12T13:06:42+00:00 app[web.1]: Caused by: java.lang.IllegalArgumentException: id to load is required for loading
2012-02-12T13:06:42+00:00 app[web.1]: at org.hibernate.event.LoadEvent.<init>(LoadEvent.java:89)
2012-02-12T13:06:42+00:00 app[web.1]: at org.hibernate.event.LoadEvent.<init>(LoadEvent.java:61)
2012-02-12T13:06:42+00:00 app[web.1]: at org.hibernate.impl.SessionImpl.get(SessionImpl.java:1002)
2012-02-12T13:06:42+00:00 app[web.1]: at org.hibernate.impl.SessionImpl.get(SessionImpl.java:998)
2012-02-12T13:06:42+00:00 app[web.1]: at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:614)
2012-02-12T13:06:42+00:00 app[web.1]: at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:589)
2012-02-12T13:06:42+00:00 app[web.1]: at play.db.jpa.JPQL.findById(JPQL.java:34)
2012-02-12T13:06:42+00:00 app[web.1]: at models.User.findById(User.java)
2012-02-12T13:06:42+00:00 app[web.1]: at controllers.UserApi.getMemberProfile(UserApi.java:470)
2012-02-12T13:06:42+00:00 app[web.1]: at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:546)
2012-02-12T13:06:42+00:00 app[web.1]: at play.mvc.ActionInvoker.invoke(ActionInvoker.java:500)
2012-02-12T13:06:42+00:00 app[web.1]: at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:476)
2012-02-12T13:06:42+00:00 app[web.1]: at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:471)
2012-02-12T13:06:42+00:00 app[web.1]: at play.mvc.ActionInvoker.invoke(ActionInvoker.java:159)
我不知道遊戲,所以只是猜測,但它可能是'user_id'爲空(因爲你使用的是一個長對象,而不是一個長基元)? – esaj 2012-02-12 14:00:15