Announcement Announcement Module
Collapse
No announcement yet.
OneToMany and ManyToOne in GAE Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • OneToMany and ManyToOne in GAE

    I found if I chose the GAE as my DB, the relationship between OneToMany and ManyToOne breaks.

    For example:
    Code:
    project --topLevelPackage me.mikeshi.bus2
    persistence setup --provider DATANUCLEUS --database GOOGLE_APP_ENGINE 
    entity --class ~.domain.Bus 
    field string name --notNull
    entity --class ~.domain.Passenger 
    field string name --notNull
    field reference --fieldName bus --type ~.domain.Bus --notNull
    focus --class ~.domain.Bus 
    field set --fieldName passengers --type ~.domain.Passenger --mappedBy bus --cardinality ONE_TO_MANY
    Because I defined the mappedBy parameter at Bus side, if I create the Bus first (let me call it Bus01), then I create the Passengers whose bus field is set to Bus01, I should get its passengers when I view the Bus01.

    Yes, if I use other DB, I could get all passengers who are assigned to the Bus01, however, I get none if I chose Google App Engine.

    I read the generated source, it seems you can get the passengers only if you set the passenger to the Bus01. But, it is very clear since I set the parameter mappedBy to the passengers field.

    I don't know whether it is a bug, however, it breaks the consistency with other DB, and if I want to port the app to other cloud platform, it will confuse me very much.

    I believe it could be improved, when getPassengers(), we can query all passengers whose bus field equals to the bus.
Working...
X