I created a view that includes a calculated field which came in with a type '

Certified Senior Developer
I created a view that includes a calculated field which came in with a type 'bigint(21)' that I can't seem to change. I'm trying to create a data type for this view but I can't seem to get it mapped correctly. I tried to make this field a 'bigint' in the xsd file using the jpa notation. I can create the data type but when I add it to the data store and try verifying the mapping, I get this error:

A type mapping annotation is invalid: identifier mapping has wrong number of columns: IPSActiveUsersVDT2506 type: integer (MappingException) (APNX-2-4055-000)

Here's my xsd file (note: I tried deleting the first jpa notation associated with the 'id' and also tried to remove the primary key on 'nbrActiveTeams' in the data type since that's not a primary key but so far nothing's helped.

<xsd:schema xmlns:xsd="www.w3.org/.../XMLSchema" xmlns:tns="urn:com:appian:types" targetNamespace="urn:com:appian:types">
<xsd:complexType name="IPS_ActiveUser...

OriginalPostID-168979

OriginalPostID-168979

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer
    ...s_v">
    <xsd:annotation>
    <xsd:documentation><![CDATA[Data Type associated with the ipsactiveusers_v (View)]]></xsd:documentation>
    <xsd:appinfo source ="appian.jpa">
                        @Table(name="ipsactiveusers_v")
               </xsd:appinfo>          
              </xsd:annotation>
               <xsd:sequence>
    <xsd:element name="id" nillable="true" type="xsd:int">
    <xsd:annotation>
    <xsd:appinfo source="appian.jpa">
                         @Id
                         @Column(columnDefinition="bigint NOT NULL")
                         </xsd:appinfo>
    </xsd:annotation>
    </xsd:element>
    <xsd:element name="lastName" nillable="true" type="xsd:string" />
    <xsd:element name="firstName" nillable="true" type="xsd:string" />
    <xsd:element name="userEmail" nillable="true" type="xsd:string" />
    <xsd:element name="appianUsername" nillable="true" type="xsd:string" />
               <xsd:element name="nbrActiveTeams" nillable="true" type="xsd:int">
    <xsd:annotation>
    <xsd:appinfo source="appian.jpa">
                         @Id
                         @Column(col...
  • 0
    Certified Senior Developer
    ...umnDefinition="bigint NOT NULL")
                         </xsd:appinfo>
    </xsd:annotation>
    </xsd:element>
               <xsd:element name="boardSuspenseDate" nillable="true" type="xsd:string" />
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
  • I've only seen that error when multiple primary keys were defined. To clarify, you tried with removing the annotations from nbrActiveTeams while leaving the @Id annotation on "id"? I would also add @Column/columnDefinition annotations on all view fields, not sure if that will help here but has seemed to make things easier for me in the past.

    On the SQL view, you may also be able to use cast(calculatedColumn as int) around the calulcated column, then map to 'int' in your XSD - if you haven't tried that already.
  • 0
    Certified Senior Developer
    Yes to your first question. I removed the @Id annotation on 'id' - just did that again and left it where it is for the nbrActiveTeams column and got this error:
    A type mapping annotation is invalid: identifier mapping has wrong number of columns: IPSActiveUsersVDT2507 type: integer (MappingException) (APNX-2-4055-000)
    If it leave it on the 'id' but take it away from the nbrActiveTeams column, I get this error:
    The data source schema does not match the type mappings: Wrong column type in Appian.ipsactiveusers_v for column nbractiveteams. Found: bigint, expected: integer (APNX-2-4056-000)
    Tried to use the cast(...as int) but that didn't seem to work
    CAST(count(`c`.`id`) AS INT) I get a syntax error.
  • When you removed the @id annotation from nbrActiveTeams, did you leave the @ColumnDefinition as 'bigint' or remove both annotations? Paste your XSD in here for your second attempt above and we'll have a look - that attempt sounds more promising.
  • 0
    Certified Senior Developer
    Based on what you wrote, I took away the @id annotation from nbrActiveTeams and it worked! Here's the final version of the XSD that worked. Thanks for the help!!

    <xsd:schema xmlns:xsd="www.w3.org/.../XMLSchema" xmlns:tns="urn:com:appian:types" targetNamespace="urn:com:appian:types">
    <xsd:complexType name="IPS_ActiveUsers_v">
    <xsd:annotation>
    <xsd:documentation><![CDATA[Data Type associated with the ipsactiveusers_v (View)]]></xsd:documentation>
    <xsd:appinfo source ="appian.jpa">
                        @Table(name="ipsactiveusers_v")
               </xsd:appinfo>          
              </xsd:annotation>
               <xsd:sequence>
    <xsd:element name="id" nillable="true" type="xsd:int">
    <xsd:annotation>
    <xsd:appinfo source="appian.jpa">
                         @Id
                         @Column(columnDefinition="bigint NOT NULL")
                         </xsd:appinfo>
    </xsd:annotation>
    </xsd:element>
    <xsd:element name="lastName" nillable="true" type="xsd:string" />
    <xsd:element name="firstName" nillable="true" type="xsd:string" />
    <xsd:element name="userEmail" nillable="true" type="xsd:string" />
    <xsd:element name="appianUsername" nillable="true" type="xsd:string" />
               <xsd:element name="nbrActiveTeams" nillable="true" type="xsd:int"/>
               <xsd:element name="boardSuspenseDate" nillable="true" type="xsd:string" />
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
  • I believe that when the database has a column whose type is bigint, putting "long" in as the type in the xsd will work
  • I see you've resolved your issue but you might find the below of interest.

    MySQL will generally return calculated integer fields in a view as bigint. You can work around this by creating a function in MySQL that takes an input of bigint and returns an integer type, and then call that function for the relevant fields in the view's select.
  • 0
    Certified Senior Developer
    Thanks for the additional suggestions!
  • I also has table with multiple primary key. Just curious appian support this design or not