Add mappedBy attribute to bidirectional relationships
Bug #722964 reported by
David Coles
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MUGLE |
Fix Released
|
High
|
Prageeth Silva |
Bug Description
Relationships that should be accessible from both sides should include a mappedBy attribute (see: http://
In particular, most of our one-to-many relations will need to be bidirectional to allow traversal from either object.
Changed in mugle: | |
status: | New → Triaged |
importance: | Undecided → High |
Changed in mugle: | |
milestone: | none → 0.1.1 |
Changed in mugle: | |
assignee: | nobody → Prageeth Silva (prageethsilva) |
tags: |
added: datastore removed: database |
Changed in mugle: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
Prageeth raises the point that we put the "mappedBy" attribute on the singleton variable, not the collection, whereas in the Google examples, it is on the collection.
For example, in http:// bazaar. launchpad. net/~mugle- dev/mugle/ trunk/revision/ 28 we have got:
Achievement.java: mappedBy= "achievements" )
@Persistent(
private Game game;
Game.java:
@Persistent
private Set<Achievement> achievements;
It probably should be the other way around. I'm not sure if it makes a difference. Also I'm not sure why you can't put the mappedBy on a many-to-many relation. Perhaps mappedBy only works if the thing you are mapping (the value of mappedBy="") is a singleton.