This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, Adding one-to-one association and updating database does not generate any foreign key. (adding and removing associaiton both says "The selected entities are up to date") I'm attaching an image and the association is highlighted (source:PlayerMatch, target:Player) Also other one-to-one association generates foriegn key for the source entity only. Shouldn't it generate for both source and target entity? I haven't changed any properties from default. I'm using the latest nightly build. Thanks. -chris |
|
|
Hi Chris, It's working for me. Note that if you select specific entities rather than updating the whole model then the difference will only be detected if you include the entity with the FK (the source): if you select the target and do an Update Database then it will say that the target is up to date. Could that be the issue? If not, can you provide us with specific steps to repro starting from a blank model (e.g. drag on two entities, right-click background and do Update Database, add one-to-one association from E1 to E2, right-click background and do Update Database)? Thanks! Regarding generation of foreign keys, the current behaviour is correct. A one-to-one association in LightSpeed is represented by a single foreign key, from source to target. If there were foreign keys at both ends, it would be impossible to insert new entities (you couldn't insert S until T had been inserted because S would have a FK to T, but you couldn't insert T until S had been inserted because T would have a FK to S). |
|
|
Hi, Ivan, Here is the step to reproduce it.
I'm attaching a sample image. Thanks. Regarding one-sided foriegn key makes sense but I have a question. How does an entity (that doesn't have foriegn key id) back-references the other entity? Does LightSpeed issue a query to find it? If so, it might be important which entity is becomes the source. I thought one-to-one association is symmetrical and I didn't care which become the source. Thanks for the info. -chris |
|
|
Hi, Ivan, Here is the step to reproduce it.
I'm attaching a sample image. Thanks. Regarding one-sided foriegn key makes sense but I have a question. How does an entity (that doesn't have foriegn key id) back-references the other entity? Does LightSpeed issue a query to find it? If so, it might be important which entity is becomes the source. I thought one-to-one association is symmetrical and I didn't care which become the source. Thanks for the info. -chris |
|
|
Thanks. It looks like this is because we're matching the foreign key to both the one-to-many and the one-to-one associations. We'll investigate and hopefully get you a fix soon. Yes, to load a one-to-one association from the non-foreign key end, LightSpeed does issue a query, just as it issues a query to load a one-to-many association from the parent end. (It's the same query in fact; internally the non-FK end of a one-to-one association is implemented as an EntityCollection, except that we ensure it never contains more than one thing.) This may be less efficient depending on your database indexing, but I would expect a foreign key column to be indexed and you would therefore not see a huge difference in performance. As always, though, measure it in your specific scenario to determine if there is a difference that will matter to your application. |
|
|
Candidate fix on its way to you in the next nightly. Let us know if you still see problems! |
|
|
It works like a charm!! Thanks a lot! -chris |
|
|
It works like a charm!! Thanks a lot! -chris |
|