Hi Appian,
I have a use case to create a CDT for an oracle table. The id is configured as below, I am trying to create CDT with not specifying the sequence using JPA Annotation @GeneratedValue ( please find example 1 XML) when I do this the datastore doesn't publish. When I tried to publish my CDT with Example 2 CDT then write to db calls fail with error : ids for this class must be manually assigned before calling save().Curious to know if we can create a CDT with no sequence and make the inserts work from Appian ?
Oracle Code for ID:
"ID" NUMBER(38,0) GENERATED BY DEFAULT ON NULL AS IDENTITY MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE NOKEEP NOSCALE NOT NULL ENABLE,
Example 1 XML:
<xsd:element name="id" nillable="true" type="xsd:int"> <xsd:annotation> <xsd:appinfo source="appian.jpa">@Id @GeneratedValue @Column(name="ID", nullable=true, columnDefinition="NUMBER")</xsd:appinfo> </xsd:annotation> </xsd:element>
Example 2 XML:
<xsd:appinfo source="appian.jpa">@Id @Column(name="ID", nullable=false, columnDefinition="NUMBER")</xsd:appinfo>
Discussion posts and replies are publicly visible
Hi ar, What is the error you getting while publishing with Example 1? I can see that the coulmn is not nullable but in XML 1 it is nullable = true. try by setting it as false.
Hi Venky thanks for the response. when I tried the code in Example 1 XML, its erroring out asking for a valid sequence. if I don't put @GeneratedValue the CDT is getting saved and datastore is being published but write to datastore fails.
Can you try with @SequenceGenerator with/without @GeneratedValue annotation.
Tried and got the below issue Venky
Please try with below XML..<xsd:element name="id" nillable="false" type="xsd:int"><xsd:annotation><xsd:appinfo source="appian.jpa">@Id @GeneratedValue @SequenceGenerator @Column(name="ID", nullable=false, columnDefinition="NUMBER")</xsd:appinfo></xsd:annotation></xsd:element>
Ran into same error where the table is expecting seq. Below is the error I see when tried the XML shared,
The data source schema does not match the type mappings: Missing sequence or table: Table_sq
Why don't you try to create the cdt from the database table directly as below.otherwise use below XML for example 2<xsd:appinfo source="appian.jpa">@Id @Column(name="ID", nullable=true, columnDefinition="NUMBER")</xsd:appinfo>
I am doing the same venky and in the process of doing that CDT is expecting a sequence but the sequence which is auto generated in oracle would change when deploying to higher environment, to avoid this to happen we are planning to not associate the table with any sequence. We dont need seq association as Oracle would assign a value when id is sent as null.
My immediate first question is why do you want to avoid @GeneratedValue? How else is the XSD supposed to understand that your Oracle code will supply the ID?
Are you doing that because Example 1 won't publish? Why not the more general question: "Why won't example 1 publish?"? It might have nothing to do with the sequence. The first thing I would check is nullable being true. Is that correct?
Hi Dave, when I put in @GeneratedValue the cdt publish is erroring out, I tried nillable="false" but that doesn't work either.
Error received : data source schema does not match the type mappings: Missing sequence or table: Table_sq
XML :
<xsd:element name="id" nillable="false" type="xsd:int"> <xsd:annotation> <xsd:appinfo source="appian.jpa">@Id @GeneratedValue @Column(name="ID", nullable=false, columnDefinition="NUMBER")</xsd:appinfo> </xsd:annotation> </xsd:element>