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
Index problem when using Object.object entity #33
Comments
Can you give exact exception stack trace instead of just the error message, please? Thanks. On Sep 16, 2011, at 3:54 PM, Aleksey Malevaniy wrote:
|
Surely, sorry. Here it is:
|
Now you can see that it is not an Orman constraint but Android SQLite implementation constraint. We also were not aware of that. If you can share your app logic with us (which column is referenced by But in most cases, parent side of foreign keys has to be unique fields since they directly point a single entry and duplicate values on that field may cause confusion. This is not related to the software that you are creating, it is about relational database theory. |
Oh, now I see, it's really obviously, thanks. Sorry for bothering. BTW, some words about my app logic and orman experience: as I'm writing some kind of messenger, I have to use wrapper methods for insert/update objects to keep consistency. So I have some ideas how framework could help with this work even in complicated situation. I'll try to share app logic and code this weekends ;-) |
One more thing. In my app I definitely have to live without UNIQUE index when creating @OnetoOne relation. In example above you can see that Message has a reference to parent Message (it creates cascade, 'cause one message could be a comment to another). And some messages has null as a parent (here comes unique violation). Is there is a way to create NOT unique index for @OnetoOne? Or how you recommend to deal with this situation? |
You can just store an integer in that field and just say that Then you can use I will think that you have an @entity called
Here you should note that
This query returns |
Thank again! I understand this approach but I tried to avoid it, because everybody wants to work with objects without any hacks :) I also tried to set unique=false but as you wrote earlier it causes sql db to break down... Now I think it would be interesting to find out how other ORMs deal with it. Maybe, there is a solution... I'll try to investigate. |
I think none of the relational DBMSes on the earth would allow you to create FK to non- If you are going to have multiple parents, then you should use |
Your're right and my weak knowledge of RDBMS. Regards, On 16 September 2011 17:23, ahmet alp balkan
|
When there is:
error occurs saying
column parent_message is not unique
It's a some kind of restriction, but! One should feel free to use unique indexes even in this situation.
P.S. everything works if I use set @Index as not unique.
The text was updated successfully, but these errors were encountered: