New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OneToOne - Couldn't find referenced element #209
Comments
Can you try a clean and rebuild? Looks like AbstractStaff isn't being processed. Creating a simple app with just @Entity(stateless = true)
public class AbstractStaff {
@Key
@Generated
protected int id;
@OneToOne(mappedBy = "staff")
protected Event owner;
}
@Entity(stateless = true)
public class AbstractEvent {
@Key @Generated
protected int id;
@ForeignKey
@OneToOne(mappedBy = "owner")
protected Staff staff;
} compiles ok. Also if you |
I did try cleaning and rebuilding which, as well as deleting the entire build folder, disabling instant run, and cleaning app data on the phone, but I still get the same warnings on build. Another one I noticed, if this is at all helpful. Running a There are two other annotation processors in the project, Dagger2 and ButterKnife 8, I don't know if there could potentially be something conflicting with them. |
Ok looks like no build errors. Looks like this can happen if you are missing a key in one of the entities. Can you provide the whole entity definition? |
Ah yes, I was missing a key in one of them, I added that in, however now I appear to be getting a different error.
And in the logcat I am getting the following exception.
|
From the exception you have a link that maybe invalid, e.g could be studentOwner which doesn't match the definition you have. Did you start from a fresh database or are you using an old one before the key column was added? Also if you use a stateless entity you should manually insert the entity that the even is referencing first instead of relying on the cascade |
Thanks for your help so far. I had made a mistake on the I have cleared out the app's data so the database should be fresh. The
That is being populated through GSON, and being inserted using |
Which order are you inserting the entities? The core of your issue is you have an invalid id studentOwner value in your Event, meaning that entity is either not inserted in the table or the entity is invalid as referenced to it. |
So I was just inserting the It appears that all of the So when inserting I tried something like
But I still appear to be getting the same error. |
I would try inserting the student first, attaching all the events to it and then updating it |
That was the solution for me... Quite strange though that Requery can't create a complete objects bunch... |
I have recently come back to my project after being too busy to work on it for a while, and I upgraded requery to the latest version (beta23), and I am now having an issue with a OneToOne relationship that I didn't previously have.
I had a read through the changelog and didn't seem to find anything which would have changed that I needed to update so I'm not entirely sure what is wrong.
My entities are as follows.
When building I get the following warnings, both listed under the
AbstractEvent
file.When trying to save something to the database, I get the following in the logcat.
The text was updated successfully, but these errors were encountered: