我在“User.findById(user_id)”处不经常出现错误,但有时,我不知道为什么。是什么导致了这个错误?
注意:我使用的是 Play 版本 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)