Embed Lists of custom objects in morphia

269 Views Asked by At

I am new to morphia and was wondering if it was possible to embed lists of custom objects in a doc while having a custom name.

e.g.,

say I have the following

ap_thing

{'_id':0,
 'name': blah,
 'cells': [
    {'row':1,
     'col':A,
     'val':'What did the pirate say when he turned 80?',
    },
    {'row':2,
     'col':A,
     'val': 'Arggg, Ay'Matey!'
    }
}

and say I want to call the outer class Thing and the inner class MyCell (thus requiring entity specifications)

How do I set up the outer and inner class to: 1) Embed a list of these cell objects 2) Allow my attribute name to be different from the Class name

In the docs they had an example where a single embedded class was used. in this example they suggested to use an annotation like @Embed("cells") in the MyCell class. Can I just do the same for lists?

1

There are 1 best solutions below

0
On BEST ANSWER

For a List, you'd use @Property("cells") e.g.