Tutorial :Google AppEngine JDO Persistence FK Arrays



Question:

I'm hoping someone's seen this. I've found no clues on Google.

I'm using Google AppEngine with JDO to persist my objects.

I have two objects, Parent and Child. Each Parent has n Child objects.

I initially stored the Child objects in an ArrayList data member in the Parent class.

I got the exception "java.lang.UnsupportedOperationException: FK Arrays not supported" when persisting the Parent object.

I put this down to my storing more than one Child key references, so changed it around so that the Child objects store key references to the Parent object instead. In this way, there is only one key reference per Child object instead of n key references per Parent object.

Yet the exception still gets thrown when persisting the Parent object. So I suspect I was mistaken about the probable cause of this exception.

Has anyone seen this exception or know what it means?


Solution:1

According to DataNucleus a lot of things are persisted by default... and they even had a complaint in their blog about the manual in the google app engine site, which said that you need to explicitly mark fields as @Persistent.


Solution:2

I figured out what was wrong.

It wasn't complaining about my ArrayList.

My Parent class had an array data member that I hadn't put an annotation on. Arrays are persisted by default in the absence of annotations.

I added the annotation @NotPersistent and this solved my problem.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »