Reputation: 9216
I have an issue with creating a transaction. I get an error back that the objects are not in the same entity group.
I have a type called Relationship and I need to create a two way relationship between two parties.
def _transaction():
relationship1 = Relationship(firstParty = party1, secondParty = party2)
relationship2 = Relationship(firstParty = party2, secondParty = party1)
db.put([relationship1 , relationship2 ])
db.run_in_transaction(_transaction)
Both of the party objects are the same type. The business rule dictates both records need to be persisted or it needs to fail. The error comes from the party objects. the properties firstParty and secondParty are Reference Properties. How can i perform a transaction on this business rule?
Upvotes: 0
Views: 402
Reputation: 14187
You need to understand entity groups before you can effectively work with transactions in app engine. Start here. In short, only entities (what you call records) in the same entity group can be involved in a transaction. By default, entities are created in their own group, so you will not be able to perform a transaction on them.
Upvotes: 3