Song Watson
Song Watson

Reputation: 75

How to save one-to-one mapping entity in greendao?

I have entityA and entityB that have a one-one relationship between them (entityA.a = entityB).

My question is: if I set entityA.a = entityB, then insert entityA, will entityB automatically be inserted?

I think it should be, but it looks like it's not.

Does that mean I should insert entityB myself?

By the way, I know I should call insert myself for a one-to-many relationship.

Upvotes: 2

Views: 1295

Answers (1)

Jofre Mateu
Jofre Mateu

Reputation: 2430

No, it won't be inserted. A relation is a link between two existing entities, you should first insert both entities and set de relation after.

Upvotes: 1

Related Questions