Cannot persist a GameData object

Bug #774677 reported by Matt Giuca
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MUGLE
Fix Released
Critical
Scott Ritchie

Bug Description

I am having trouble creating GameData objects and persisting them in the database. I created a GameData object like this (in DataTestServiceImpl.populateDatastore):

      GameData[] games = new GameData[] {
                                        new GameData("test", devteams[0])
                                      };
      pm.makePersistentAll(games);

Then, clicking the Populate button results in this error at runtime:

> The owner field game of element class
> au.edu.unimelb.csse.mugle.server.model.AchievementData
> has an incorrect type "au.edu.unimelb.csse.mugle.shared.model.Game". Should
> be "au.edu.unimelb.csse.mugle.server.model.GameData"

That is on the line:
    pm.makePersistentAll(games);

I assume this is because we have a class GameData which has a Set<AchievementData> mappedBy "game", but the AchievementData's game field has type Game. I believe that AchievementData's game field should have type GameData. Am I correct?

I replaced all uses of the Game type in AchievementData with GameData. This fixes that error, but now it generates another exception on the same line:

> Class "au.edu.unimelb.csse.mugle.server.model.GameData" has collection
> field "achievements" and this has no mapping in the table for the element
> class "au.edu.unimelb.csse.mugle.server.model.AchievementData" owner
> field "game"

I can't figure this one out. The GameData.achievements field has type Set<AchievementData> mappedBy "game", and the AchievementData.game field has type GameData. This seems to be the normal way of doing things in https://code.google.com/appengine/docs/java/datastore/jdo/relationships.html, so why is it giving this error?

Revision history for this message
Matt Giuca (mgiuca) wrote :

I have fixed the first exception (Game -> GameData) in trunk r115. Now stuck on the second one.

description: updated
Scott Ritchie (sritchie)
Changed in mugle:
assignee: nobody → Scott Ritchie (sritchie)
Revision history for this message
Scott Ritchie (sritchie) wrote :

Im not getting this error yet - its currently failing at making the DevTeam Persistent:

00:08:08.757 [ERROR] javax.servlet.ServletContext log: Exception while dispatching incoming RPC call com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract java.lang.String au.edu.unimelb.csse.mugle.client.DataTestService.populateDatastore()' threw an unexpected exception: org.datanucleus.exceptions.NucleusException: App Engine ORM does not support multiple parent key provider fields.
......
at au.edu.unimelb.csse.mugle.server.DataTestServiceImpl.populateDatastore(DataTestServiceImpl.java:61)

I've done a quick search and come up with:
As the exception states, on App Engine an Entity cannot have multiple parents. This
is because OneToMany is tied to the concept of ancestor in the datastore. Each
entity can only have one direct ancestor.

I'll see what can be done, but i think what will end up happening is i'll have to change all the relations in the code to be unowned, so that theyre sets of keys with no mappings.
This will also fix the issue with the Game mapping.

Revision history for this message
Scott Ritchie (sritchie) wrote :

I've updated the ER Diagram in revision 118 to reflect the changes i plan to implement. Let me know if you disagree with which relation I've designated as owned or unowned in the updated diagram

Revision history for this message
Matt Giuca (mgiuca) wrote :

Well I'm getting an exception persisting the DevTeam as well, but only the first time. If you click again, it should work.

But yeah, okay. If unowned works, let's go with that. It seems like the difference between owned vs unowned is that owned is better for type safety, but unowned works more often. Seems like an annoying distinction (I like things with type safety that work), but given the choice, go with unowned.

That just means replacing all of the actual object types with 'Key', right?

Revision history for this message
Scott Ritchie (sritchie) wrote :

Making them all unowned has worked, need to make sure all the getters and setters are correct now that we're managing our own relations and will commit a fix

Changed in mugle:
status: Triaged → In Progress
Scott Ritchie (sritchie)
Changed in mugle:
status: In Progress → Fix Committed
Revision history for this message
Scott Ritchie (sritchie) wrote :

Fixed in revision 119,
But new bugs #744035 and #774929 have been raised.

Matt Giuca (mgiuca)
Changed in mugle:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.