Thank you, James! Obviously, that was in fact my problem. In lieu of proper documentation, I have now taken to trudging through that XSD, and trying to decipher it, to tackle other problems I've been having too. That was very helpful, thank you.
Maybe I'll throw out today's problem to see if it rings a bell. Again, using EL2.5+Mongo+XML Mappings, I have an object with a subobject (not embedded) and it persists correctly to Mongo:
<entity name="Waction" class="com.x.waction.Waction">
<no-sql data-format="MAPPED" />
<attributes>
<id name="_id">
<generated-value />
</id>
<many-to-many name="events" fetch="EAGER" target-entity="com.x.event.Event">
<cascade>
<cascade-all />
</cascade>
</many-to-many>
</attributes>
</entity>
<entity class="com.x.event.SimpleEvent">
<no-sql data-format="MAPPED" />
<attributes>
<id name="_id">
<generated-value />
</id>
<basic name="timeStamp" />
</attributes>
</entity>
In Mongo, after persisting, I see the primary object and the subobject, with the proper link between them:
> db.WACTION.find().pretty()
{
"_id" : ObjectId("51a8d63b3004eef2587bcdd0"),
"_ID" : "51A8D63B3004EEF2587BCDCE",
"EVENTS__ID" : [
"51A8D63B3004EEF2587BCDCF"
]
}
> db.EVENT.find().pretty()
{
"_id" : ObjectId("51a8d63b3004eef2587bcdd1"),
"DTYPE" : "SimpleEvent",
"TIMESTAMP" : NumberLong(0),
"_ID" : "51A8D63B3004EEF2587BCDCF",
"DBID" : "null"
}
But when I select the WACTION from the database, it comes back with an "events" list containing zero items:
EntityManager em = factory.createEntityManager();
em.getTransaction().begin();
Object result = em.find(Waction.class, objectId);
if(result instanceof Waction) {
Waction w = (Waction) result;
List<Event> evs = w.getEvents();
int evsSize = evs.size();
...
and 'evsSize' is zero. You see I made that many-to-many mapping fetch=EAGER.