This is a migrated thread and some comments may be shown as answers.

Incompatible State : error in Telerik ORM

3 Answers 140 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ujjwal Manna
Top achievements
Rank 1
Ujjwal Manna asked on 24 Mar 2010, 12:05 PM
Hi All,

 

Currently I am facing one telerik open access error. It would be great if you can help on this. The error message like below : 

(See Pic1) 

The model diagram looks like below snapshot :

(See Pic2) 

 

Each different class (MtSubmitter,MtInventor,MtStaffMember,MtCorrespondent,MtValidator,MtMeetingLeader) mapped with different View.

 

 

(See Pic3) 

 

After Implementing the different QuickSearchMethod of different class, If I execute any QuckSearchMethod(Ex:- QuckSearckCorrespondent) , its working fine .

 

 

(See Pic4) 

Now if I execute any other QuickSearchMethod(Ex:-QuickSearchInventor), I am getting the above error.

Similarly if I execute QuickSearchStaffMember, I am also getting the same error.

(See Pic5) 

 

(i.e After running application ,if I execute any QuickSerachMethod it may be QuckSearckCorrespondent,it may be QuickSearchInventor etc.. its working fine,but after executing one QuickSearchMethod if I execute other QuickSearchMethod I am getting the above error.)

After debugging on QuickSearchMethod(Ex:-QuickSearchInvention) I am getting the below information :

(See Pic6) 

If I execute the Sql query explicitly I am getting the data,but not understand why I am getting the above error.

SELECT a."NAMEKEY" COL1, a."BIRTHDAY" COL2, a."COMPANYKEY" COL3, a."COMPANYKEY" COL4, a."COMPANYNAME" COL5, 
a."FIRSTNAME" COL6, a."FUNCTIONNAME" COL7, a."INITIALS" COL8, a."MIDDLEINITIALS" COL9, a."MIDDLENAME" COL10, a."GENDER" COL11, 
a."NAMEINFORMATION" COL12, a."TITLEKEY" COL13, a."NATIONALITYCOUNTRYKEY" COL14, a."NATIONALITYCOUNTRYKEY" COL15, 
a."OFFICENUMBER" COL16, a."TITLEKEY" COL17, b."NAMECODE" COL18, b."CURRENCYKEY" COL19, b."DATECEASED" COL20, 
b."DATESTART" COL21, b."EMAIL" COL22, b."LANGUAGEKEY" COL23, b."LDAPUNIQUEID" COL24, 
b."CURRENCYKEY" COL25, b."LANGUAGEKEY" COL26, b."LOTUSNOTESUNIQUEID" COL27, b."NAME" COL28, b."ENTITYTYPE" COL29, 
b."PARENTNAMEKEY" COL30, b."TIMECODE" COL31, b."TIMERATE" COL32, b."NAME" xj1 FROM "VWINVENTORINDIVIDUAL" a JOIN 
"NAME" b ON (a."NAMEKEY" = b."NAMEKEY"WHERE (1=1) 

The QuickSearchMethod(Ex:-QuickSearchInventor) has been written like below snapshot :

 

public Collection<Inventor> QuickSearchInventor(string pSearchText, string[] pSearchFields, int pStartFrom, int pFetchCount, bool pIsShowAll, InvokeContext ctx) 
{   
  Collection<Inventor> serviceResult = null;  
   try  
     { 
       using (IObjectScope scope = NameScopeProvider.GetNewObjectScope())  
       {  
         IQueryable<MtInventor> result;  
         result =from c in scope.Secure<MtInventor>()  
                 where true 
                 orderby c.Name 
                 select c; 
         var cnt = result.Count<MtInventor>(); 
         if (result.Count<MtInventor>() > 0) 
         { 
            serviceResult =new Collection<Inventor>(); 
            using (NameComponentFacade<MtInventor, Inventor> mapper = new NameComponentFacade<MtInventor, Inventor>()) 
            {  
              foreach (MtInventor modelRecord in result) 
              { 
                if (!String.IsNullOrEmpty(pSearchText)) 
                { 
                   bool isRecordMatchWithFilterCriteria = CommonHelper.IsMatch(modelRecord, pSearchText, pSearchFields); 
                  if (!isRecordMatchWithFilterCriteria) continue
                } 
                serviceResult.Add(mapper.GetContractObject(modelRecord)); 
               } 
               if (pFetchCount != 0 && pFetchCount >= 0 && !pIsShowAll) 
               { 
                  serviceResult =new Collection<Inventor>(serviceResult.Skip(pStartFrom).Take(pFetchCount).ToList<Inventor>()); 
      
                } 
              } 
            } 
          } 
    } 
    catch (Exception ex) 
    { 
        throw new Exception("Error in retrieving records : (" + ex.Message + ")", ex); 
    } 
    return serviceResult;  

It would be great if you can give some idea for resolving this issue.

Thank you for your kind assistance.

Best Regards,

Ujjwal

3 Answers, 1 is accepted

Sort by
0
Jan Blessenohl
Telerik team
answered on 26 Mar 2010, 06:17 PM
Hi Ujjwal Manna,
If you map a class hierarchy to one table we use a class-id ot discriminator column to derive a type from a row. Your view now returns a row that has a different class-id as expected, exactly like the exception tells you.
 
Can you filter your views by the class id?

All the best,
Jan Blessenohl
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Ujjwal Manna
Top achievements
Rank 1
answered on 27 Mar 2010, 10:55 AM

Hi Jan,

Thanks for your kind reply. Actually the problem was, one "namekey" (Available on "Name" class )   can be used for multiple case (Ex-MtSubmitter,MtInventor etc..)
thats why we did the vertical mapping where each class is mapped with different view.   I know that we can use the discriminator column but it can be used only for "Flat:" mapping.

My app.config (I removed some mapping part for make it more readable) and it looks like below : 

<class name="MtName">  
   <extension key="db-key-generator" value="HIGHLOW" /> 
      <extension key="db-table-name" value="NAME" /> 
          <field name="nameKey">  
              <extension key="db-column">  
                <extension key="db-column-name" value="NAMEKEY" />  
              </extension>  
           </field>  
           <field name="name" > 
              <extension key="db-column"
                <extension key="db-column-name" value="NAME" />  
              </extension>  
            </field> 
        <extension key="db-class-id" value="{no}" />  
  <class> 
  
 <class name="MtNameIndividual"
    <extension key="db-inheritance" value="vertical" /> 
    <extension key="db-table-name" value="NAMEINDIVIDUAL" /> 
    <field name="birthday"
       <extension key="db-column">  
            <extension key="db-column-name" value="BIRTHDAY" />  
             </extension>  
     </field> 
    <field name="companyKey"
      <extension key="db-column"
          <extension key="db-column-name" value="COMPANYKEY" /> 
      </extension> 
    </field> 
    <field name="firstName"
     <extension key="db-column"
        <extension key="db-column-name" value="FIRSTNAME" /> 
     </extension> 
    </field>  
  </class> 
  
 <class name="MtInventor">  
    <extension key="db-table-name" value="VWINVENTORINDIVIDUAL" /> 
       <extension key="db-inheritance" value="vertical" />  
       <field name="companyName">  
          <extension key="db-column"
            <extension key="db-column-name" value="COMPANYNAME" />  
           </extension>  
        </field>  
 </class> 
  
 <class name="MtCorrespondent">  
    <extension key="db-table-name" value="VWCORRESPONDENTINDIVIDUAL" />  
     <extension key="db-inheritance" value="vertical" />  
      <field name="companyName"
            <extension key="db-column">  
                <extension key="db-column-name" value="COMPANYNAME" />  
              </extension>  
       </field> 
 </class> 
In below please find the updated sql query :

SELECT a."NAMEKEY" COL1, a."COMPANYNAME" COL2, a."NAMEINFORMATION" COL3, b."BIRTHDAY" COL4, b."COMPANYKEY" COL5,  
 b."COMPANYKEY" COL6, b."FIRSTNAME" COL7, b."FUNCTION" COL8, b."INITIALS" COL9, b."MIDDLEINITIALS" COL10, b."MIDDLENAME" COL11,  
  b."GENDER" COL12, b."TITLEKEY" COL13, b."NATIONALITYCOUNTRYKEY" COL14, b."NATIONALITYCOUNTRYKEY" COL15, b."OFFICENUMBER" COL16,   
  b."TITLEKEY" COL17, c."NAMECODE" COL18, c."CURRENCYKEY" COL19, c."DATECEASED" COL20, c."DATESTART" COL21, c."EMAIL" COL22,   
  c."LANGUAGEKEY" COL23, c."LDAPUNIQUEID" COL24, c."CURRENCYKEY" COL25, c."LANGUAGEKEY" COL26, c."LOTUSNOTESUNIQUEID" COL27,   
  c."NAME" COL28, c."ENTITYTYPE" COL29, c."PARENTNAMEKEY" COL30, c."TIMECODE" COL31, c."TIMERATE" COL32,   
  c."NAME" xj1 FROM "VWINVENTORINDIVIDUAL" a JOIN "NAMEINDIVIDUAL" b ON (a."NAMEKEY" = b."NAMEKEY"JOIN "NAME" c   
  ON (a."NAMEKEY" = c."NAMEKEY")   
WHERE (1=1) ORDER BY c."NAME"   
 

In below,please find the script of a view

CREATE OR REPLACE FORCE VIEW VWINVENTORINDIVIDUAL  
AS 
   SELECT C."NAME" COMPANYNAME, A."NAMEKEY",b."NAME" 
          || ',' 
          || a."FIRSTNAME" 
          || '(' 
          || a."INITIALS" 
          || ')' NAMEINFORMATION  
     FROM "NAMEINDIVIDUAL" A JOIN "NAME" B ON (A."NAMEKEY" = B."NAMEKEY")  
          LEFT OUTER JOIN "NAME" C ON (C.NAMEKEY = A.COMPANYKEY)  
    WHERE EXISTS (SELECT 1  
                    FROM "VALIDNAMENAMETYPE" C  
                   WHERE A."NAMEKEY" = C."NAMEKEY" AND C."NAMETYPEKEY" = 209); 

But still, I am getting the  error.  

"Error in retrieving records :(

Incompatible states: supplied stateMemotech.Directories.Names.NameComponent.Model.MtInventor: Required Memotech.Directories.Names.NameComponent.Model.MtCorrespondent)"

According to your suggestion,can you please kindly elaborate how we can do that?
Thanks in advance.
Regards,
Ujjwal

0
Jan Blessenohl
Telerik team
answered on 01 Apr 2010, 03:38 PM
Hello Ujjwal Manna,
Got your problem, you have one column that maps to different fields in dervied classes. This is a supported feature in flat mapping. If you make a class hierarchy and have two fields in tow derived classes you can name them differently and map them to the same column (if the types are compatible).

I am not able to reproduce your problem here, if you are not able to use flat mapping you should send me an example program (can be compiled) plus an empty database or ddl script so that i can run it here.

All the best,
Jan Blessenohl
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Data Access Free Edition
Asked by
Ujjwal Manna
Top achievements
Rank 1
Answers by
Jan Blessenohl
Telerik team
Ujjwal Manna
Top achievements
Rank 1
Share this question
or