Note that there are some explanatory texts on larger screens.

plurals
  1. POplay2 mongodb many-to-many relationship error
    text
    copied!<p>I'm developing an application with play framework 2 and mongoDb. For the mapping to the database i am using morphia. One feature of the app is that users can connect to each other (similar to the friends part of facebook). To model this m:m relationship i decided to put the ObjectId of all friends in an array of the user's document like this:</p> <pre><code>{ ..., "friends" : [ ObjectId("515438e5385541456e6123"), ObjectId("515438e5385541456e8599") ], ... } </code></pre> <p>The problem is, after two users become friends, so in the array of them is the ObjectId of the other user and i try to get all users from mongo (or similar operations depending on users), the system crashs with following output:</p> <pre><code>/usr/local/play-2.1.0/framework/build: line 11: 366 Illegal instruction: 4 java ${DEBUG_PARAM} -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=384M ${JAVA_OPTS} -Dfile.encoding=UTF-8 -Dplay.version="${PLAY_VERSION}" -Dsbt.ivy.home=`dirname $0`/../repository -Dplay.home=`dirname $0` -Dsbt.boot.properties=`dirname $0`/sbt/sbt.boot.properties -jar `dirname $0`/sbt/sbt-launch.jar "$@" </code></pre> <p>Im very confused about this error. The entries in mongoDb are correct. Here is my update method, maybe here is something leading to an error:</p> <pre><code>UpdateOperations&lt;User&gt; ops = MorphiaFactory.datastore.createUpdateOperations(User.class).add("friends", new ObjectId(friendId)); MorphiaFactory.datastore.update(queryToFindMe(), ops); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload