Print Page | Close Window

Unable to create relation

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1085
Printed Date: 24-Apr-2025 at 1:35am


Topic: Unable to create relation
Posted By: kjohnson
Subject: Unable to create relation
Date Posted: 05-Feb-2009 at 7:59am
I'm currently getting an error returned when I try and retrieve data through an entityrelation.  It is specifically between two tables, CompanyInfo (contains basic information on a company) and InvStoreQuantity (records that say location X has quantity Y of a particular item).  Within SQL Server 2005 I created the relation between them on the field CompanyCode (which is the primary key of CompanyInfo) with a data type of long integer in both tables.  Going through the Object Mapper, I have made sure that both tables are using the same data type.
In my actual query, I'm building the rdbquery on the table CompanyInfo, and doing an addspan to cover the relation EntityRelations.CompanyInfo_InvStoreQuantities.  When the query tries to run, the following error comes up: 

{"Unable to create relation 'CompanyInfo_InvStoreQuantity' because of an underlying column datatype mismatch \n Column 'CompanyCode' DataType 'System.Int64' != Column 'CompanyCode' DataType 'System.Decimal'"}

I have checked the data type in the database, in the object mapper, and in my customized code(such as the Create method) and each of these are set to use the Int64 data type.  Is there somewhere else that might be throwing this off?



Replies:
Posted By: davidklitzke
Date Posted: 05-Feb-2009 at 8:34am
Is the relationship defined in the Object Mapper.  If not, try to use the Object Mapper to create the relationship.  Let me know if the Object Mapper has difficulties creating the relationship.


Posted By: kjohnson
Date Posted: 05-Feb-2009 at 8:39am
The relationship is present in the Object Mapper.  It currently shows up with a relation name of CompanyInfo_InvStoreQuantity, cardinality OneToMany, and joined on CompanyCode=CompanyCode.

The relation was created when I added the CompanyInfo and InvStoreQuantity tables to the Object Mapper.


Posted By: kimj
Date Posted: 06-Feb-2009 at 11:21am
Double check, on the Simple Properties tab for both entities, both the "DataType" and "SourceDataType" values to ensure something wasn't accidentally modified.
 
If everything looks good, then post the declaration for the specific EntityRelation here, as well as the corresponding EntityColumn declarations.   
 
Also, are you using a custom DataSourceMappingInterceptor?


Posted By: kjohnson
Date Posted: 06-Feb-2009 at 11:50am
Both the "DataType" and "SourceDatType" values come up as System.Int64.

Following are the declarations you requested:

    /// <summary>
    /// Represents a parent/child relationship between
    /// <see cref="CompanyInfo"/> and <see cref="InvStoreQuantity"/>.
    /// </summary>
    public static EntityRelation CompanyInfo_InvStoreQuantity = new EntityRelation(
      new EntityColumn[] { CompanyInfo.CompanyCodeEntityColumn },
      new EntityColumn[] { InvStoreQuantity.CompanyCodeEntityColumn },
      false,
      "CompanyInfo_InvStoreQuantity");

//CompanyInfoDataRow
     /// <summary>The CompanyCode <see cref="T:IdeaBlade.Persistence.EntityColumn"/>.</summary>
    public static readonly EntityColumn CompanyCodeEntityColumn =
      new EntityColumn(typeof(CompanyInfo), "CompanyCode", typeof(System.Int64), false, true, false, DataSourceAccessType.ReadWrite);

//InvStoreQuantityDataRow
    /// <summary>The CompanyCode <see cref="T:IdeaBlade.Persistence.EntityColumn"/>.</summary>
    public static readonly EntityColumn CompanyCodeEntityColumn =
      new EntityColumn(typeof(InvStoreQuantity), "CompanyCode", typeof(System.Int64), true, false, false, DataSourceAccessType.ReadWrite);


Posted By: kjohnson
Date Posted: 06-Feb-2009 at 11:53am
I have not made a custom DataSourceMappingInterceptor.  Could using one potentially solve this problem?


Posted By: kimj
Date Posted: 06-Feb-2009 at 12:29pm
A DataSourceMappingInterceptor could be a workaround for the problem but hopefully there's a simpler answer, since technically this problem shouldn't exist (we have relations joining Int64 and nullable Int64 columns all over our test suite).
 
Which version of DevForce are you using?
 
I hate to ask this, but we'll need a small sample which reproduces this problem in order to help further.   You can send it to mailto:support@ideablade.com. - support@ideablade.com.
 


Posted By: Igar
Date Posted: 23-Mar-2009 at 3:44am
I have the same problem.

I use uniqueidentifier as a key, so the error message is
Unable to create relation 'XXX_XXX' because of an underlying column datatype mismatch \n Column 'Id' DataType 'System.String' != Column 'CustomerId' DataType 'System.Guid'.

IdeaBlade version is 3.6.3.3. I've checked types of database fields and object mapper — all's ok.

Unfortunally this is occasionally problem and probably it is connected with multithreading.

Are there any news about the problem?


Posted By: davidklitzke
Date Posted: 23-Mar-2009 at 9:44am

The problem occurs because the Object Mapper cannot onvert from the string representation of a System.Guid to a System.Guid even if the string representation pf the System.Guid is completely legal.

To solve this problem, you will likely need a custom DataMappringInterceptor.


Posted By: kimj
Date Posted: 23-Mar-2009 at 11:27am
Several multi-threading issues were fixed in v 3.6.4 released last fall.  The current version of DevForce Classic is 3.6.6.  If the problem persists after upgrading to the latest version, please let us know.



Print Page | Close Window