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
|
I have a basic model for a Vector: <entities> <entity name="Value" identityType="Int32" cacheExpiry="0">
<oneToManyAssociations> <oneToManyAssociation Id="30660e8f-9bf4-489f-8425-3bb8ebfd2b87" collectionName="VectorContents" backreferenceName="Value" isNullable="false"> <entityMoniker name="/Model/VectorContents" /> </oneToManyAssociation> </oneToManyAssociations> </entity> <entity name="Vector" identityType="Int32" cacheExpiry="0"> <oneToManyAssociations> <oneToManyAssociation Id="07c4ccbd-7c8c-4cb6-bf07-ab3d68e00043" collectionName="Values" backreferenceName="Vector" isNullable="true"> <entityMoniker name="/Model/Value" /> </oneToManyAssociation> </oneToManyAssociations> </entity> <entity name="VectorContents" identityType="Int32" cacheExpiry="0"> <oneToManyAssociations> <oneToManyAssociation Id="69f66555-1362-4d1e-9f23-2df25d221b85" collectionName="Vectors" backreferenceName="VectorContents" isNullable="false"> <entityMoniker name="/Model/Vector" /> </oneToManyAssociation> </oneToManyAssociations> </entity> </entities> When I try to create a Value, I get a System.StackOverflowException.
Any ideas? This seems like a basic construct to me:
![]() |
|
|
We don't permit this construct because it has a circular dependency: Value has a FK to Vector, Vector has a FK to VectorContents, and VectorContents has a FK to Value. LightSpeed doesn't allow this because we determine insert and delete order at a table level (inserts are performed on target tables before the tables that refer to them), and this scenario makes it impossible for us to figure out which kind of entity to insert or delete first. That said, we should be detecting this when we perform our circularity checks and issuing a meaningful error, rather than infinitely recursing when you try to create one of the objects. I've logged bugs for the designer and the runtime to improve this. Thanks for reporting this issue. |
|
|
Hi Ivan, I understand why it is happening. However, this seems to me to be a valid construct for a database. Basically, I want to have an abstract Value type, and containers for those. Lists, Vector, Map etc. Currently, I am really struggling as to how to do this with Lightspeed. It is easy enough to do this 'manually'. Is there some work-around to allow for these recursively defined structures? Note that the meta-structure only is recursive; there is not necessarily any recursion in the data itself. I tried setting the connections to be nullable in the hope that the circularity checks can be delayed; to no avail. Alternatively, perhaps you have a suggestion for an alternate approach to modelling this? Thanks, Christian
|
|
|
For anyone watching at home, a solution is to use single-table inheritance: Where Value is a (non-abstract!) base, and StrValue, NumValue, Vector and Map all derive from it via a ValueTypeId FK discriminator. And look ma, no circular references.
|
|