Setting primary key

Hello ,

I have a requirement where i need to set the primary key of the cdt through an xsd and not using the interface .Which annotation can be used for the same ? I tried searching through existing CDT's for the setting primary key annotation but was not able to find one. Any help will be appreciated.

Thanks,

Rohit Ouhal

  Discussion posts and replies are publicly visible

Parents
  • Hi rohitr303 ,

    @Id, is used for setting Primary Key . Please find below an Example of Employee CDT , where id is set as Primary Key with JPA annotation @Id

    <xsd:schema xmlns:xsd=""

    xmlns:tns="urn:com:appian:types:example"

    targetNamespace="urn:com:appian:types:example">

     <xsd:complexType name="Employee">

       <xsd:sequence>

         <xsd:element name="id" nillable="true" type="xsd:int">

           <xsd:annotation>

             <xsd:appinfo source="appian.jpa">

                 @Id

                 @GeneratedValue

             </xsd:appinfo>

           </xsd:annotation>

         </xsd:element>

         <xsd:element name="firstName" type="xsd:string" />

         <xsd:element name="lastName" type="xsd:string" />

       </xsd:sequence>

     </xsd:complexType>

    </xsd:schema>

Reply
  • Hi rohitr303 ,

    @Id, is used for setting Primary Key . Please find below an Example of Employee CDT , where id is set as Primary Key with JPA annotation @Id

    <xsd:schema xmlns:xsd=""

    xmlns:tns="urn:com:appian:types:example"

    targetNamespace="urn:com:appian:types:example">

     <xsd:complexType name="Employee">

       <xsd:sequence>

         <xsd:element name="id" nillable="true" type="xsd:int">

           <xsd:annotation>

             <xsd:appinfo source="appian.jpa">

                 @Id

                 @GeneratedValue

             </xsd:appinfo>

           </xsd:annotation>

         </xsd:element>

         <xsd:element name="firstName" type="xsd:string" />

         <xsd:element name="lastName" type="xsd:string" />

       </xsd:sequence>

     </xsd:complexType>

    </xsd:schema>

Children
No Data