How to specify the uniqueidentifier datatype of SQL SERVER in XSD type?...

How to specify the uniqueidentifier datatype of SQL SERVER in XSD type?...

OriginalPostID-104088

OriginalPostID-104088

  • These annotations will map to a primary key in SQL Server that is of type auto-increment if that is what you need

    @Id
    @GeneratedValue

    Example:
    <xsd:element name="id" type="xsd:int">
    <xsd:annotation>
    <xsd:appinfo source="appian.jpa">
    @Id
    @GeneratedValue
    </xsd:appinfo>
    </xsd:annotation>
    </xsd:element>
  • I was trying to map the existing table structure in the SQLSERVER which has a field having the type "uniqueidentifier" to the XSD structure. Does the XSD has the type called "uniqueIdentifiier"? if not, how can we map that field to the existing table?
  • There's no JPA annotation for this type of column. The following syntax is only compatible at the Hibernate level but not at the JPA level

    @GenericGenerator(name = "generator" strategy = "guid")
    @GeneratedValue(generator = "generator")
  • Did this end up working for you? Most of our tables have at lease one uniqueidentifier item in them.
  • I am also looking to map existing table to a cdt which has many unique identifier, any solution for this?
  • You may want to try something like this:

    @Id
    @GenericGenerator(name = "generator", strategy = "guid", parameters = {})
    @GeneratedValue(generator = "generator")
    @Column(name = "APPLICATION_ID" , columnDefinition="uniqueidentifier")
  • hello eduardo, when trying to use above annotation, and trying to import the cdt, get the below error:
    A type mapping annotation is invalid: Found Array End (}) but expected one of : Annotation, Value (e.g. String, int), Attribute Name. @Id @GenericGenerator(name = "generator", strategy = "guid", parameters = {}_) @GeneratedValue(generator = "generator") @Column(name = "prospect_name", columnDefinition="uniqueidentifier") Current lexeme: } (APNX-2-4055-000)

    Below is the column, that i am trying to map a column:

    <xsd:element name="prospectName" nillable="true" type="xsd:string">
    <xsd:annotation>
    <xsd:appinfo source="appian.jpa">
                         @Id
    @GenericGenerator(name = "generator", strategy = "guid", parameters = {})
    @GeneratedValue(generator = "generator")
    @Column(name = "prospect_name", columnDefinition="uniqueidentifier")
                                  </xsd:appinfo>
    </xsd:annotation>
    </xsd:element>
  • @Id
    Try this instead:


    @GenericGenerator(name = "generator", strategy = "guid")
    @GeneratedValue(generator = "generator")
    @Column(name = "APPLICATION_ID" , columnDefinition="uniqueidentifier")
  • @Id
    @GenericGenerator(name = "generator", strategy = "guid")
    @GeneratedValue(generator = "generator")
    @Column(name = "APPLICATION_ID" , columnDefinition="uniqueidentifier")
  • For your example it would be:

    @Id
    @GenericGenerator(name = "generator" strategy = "guid")
    @GeneratedValue(generator = "generator")
    @Column(name = "prospect_name" columnDefinition="uniqueidentifier")
  • Getting this error:

    A type mapping annotation is invalid: The eclass: HbAnnotatedEAttribute does not have an efeature for GenericGenerator (APNX-2-4055-000)

    for code: <xsd:element name="prospectName" nillable="true" type="xsd:string">
    <xsd:annotation>
    <xsd:appinfo source="appian.jpa">
                         @Id
    @GenericGenerator(name = "generator", strategy = "guid")
    @GeneratedValue(generator = "generator")
    @Column(name = "prospect_name" , columnDefinition="uniqueidentifier")
                                  </xsd:appinfo>
    </xsd:annotation>
    </xsd:element>
  • I just re-read my previous comment and it says: "The following syntax is only compatible at the Hibernate level but not at the JPA level" so definitely these won't work with JPA.

    This works for validation but still tries to pass the primary key as an empty string in the insert failing to do so
    <xsd:annotation>
    <xsd:appinfo source="appian.jpa">
                                  @Id
                                  @GeneratedValue
                                  @Column(name = "UniqueColumn" columnDefinition="uniqueidentifier")
                        </xsd:appinfo>
    </xsd:annotation>

    I think the answer is still the same and JPA doesn't support this.
  • So How can we accomplish this in mapping the cdt to existing db table.
  • I would say:

    - Using the Query RDBMS smart service and manually mapping the outputs to a CDT
    - Building a custom smart service
  • But our goal is to get the data as a record using data entity record..........

 Discussion posts and replies are publicly visible