Nullpointerexception throws when inserting entity using Auto-generated Classendpoint insert method

后端 未结 2 852
刺人心
刺人心 2021-01-12 10:01

I am confused to using auto-generated endpoint class. I want to use generated endpoint to insert new object into datastore. But, an exception is throwing.

f         


        
2条回答
  •  悲&欢浪女
    2021-01-12 10:47

    I was having the same exact problem after using the Eclipse Plugin to autogenerate the cloud endpoints (by selecting "Google > Generate Cloud Endpoint Class").

    Following your advice, I added:

    if(foo.getID() == null) // replace foo with the name of your own object return false;

    The problem was solved.

    How is that Google hasn't updated the autogenerated code yet as this must be a highly recurring issue?

    Thanks for the solution.

提交回复
热议问题