How to implement an unowned one-to-many relationship in Siena/GAE

50 views
Skip to first unread message

Willem Salembier

unread,
Feb 16, 2012, 7:08:18 AM2/16/12
to siena-...@googlegroups.com
The documentation explains Many<T> relations implemented as owned, aggregated or embedded relationships.
But how do I implement an unowned one-to-many relation?

In GAE, this implemented by storing a List<Key> objects in the parent object. The child object represented by a Key has its own lifecycle.

In Siena I can't use
- owned -> because it requires a link from the child to the parent back
- aggregated -> because child and parent are one entity group and the child gets duplicated
- embedded -> because i can't query this structure natively in GAE because it is represented as a YAML string.

Any suggestions?

Pascal Voitot Dev

unread,
Feb 16, 2012, 7:59:07 AM2/16/12
to siena-...@googlegroups.com
Hi,

You can't use List<Key> in Siena because Siena abstracts the GAE Key type.
But you can store directly a List<Long> where the long is the ID of the linked entity.

It should be work without any pb!

Pascal

--
You received this message because you are subscribed to the Google Groups "Siena" group.
To view this discussion on the web visit https://groups.google.com/d/msg/siena-discuss/-/6Z84CDkBHHEJ.
To post to this group, send email to siena-...@googlegroups.com.
To unsubscribe from this group, send email to siena-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/siena-discuss?hl=en.

Willem Salembier

unread,
Feb 16, 2012, 8:07:41 AM2/16/12
to siena-...@googlegroups.com
This is an option, but not a pretty one because I loose the retrieval of the linked entities using Many.asList() or asQuery().

I was hoping I could define something like this:

@Referenced
Many<T> relations;

so SIENA on GAE whould persist this relation as a List<Long> or List<Key>

Pascal Voitot Dev

unread,
Feb 16, 2012, 8:40:11 AM2/16/12
to siena-...@googlegroups.com
yes it would be great but it's not implemented like that, yet :)
Sorry...
If you feel like doing this work, don't hesitate to contribute (as I said several times, I don't have time to support Siena anymore as I work a lot on other stuff :( )

Pascal

--
You received this message because you are subscribed to the Google Groups "Siena" group.
To view this discussion on the web visit https://groups.google.com/d/msg/siena-discuss/-/Dix1F8kQF9oJ.
Reply all
Reply to author
Forward
0 new messages