Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Suggested Answer
+2
person also asked this
people also asked this
Replies
16 replies
Answers
4 answers
Subscribers
10 subscribers
Views
16265 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
How do we map a CDT to a database view??/ Any documentation related to vie
raghunandanj3904
Certified Senior Developer
over 11 years ago
How do we map a CDT to a database view??/
Any documentation related to views & CDT is very helpful.
We tried creating a CDT with annotations but it creates a table in the DB. Is there any extra anootations / tags we need to take crae for views. We have created a view in the database in MS SQL....
OriginalPostID-76078
OriginalPostID-76078
Discussion posts and replies are publicly visible
0
raghunandanj3904
Certified Senior Developer
over 11 years ago
I tried with the approach explained here:
forum.appian.com/.../apps
But when we try to verify with the datastore, it adds a_id as the identifier.
Can someone help us with an example CDT.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
+1
colton.beck
Appian Employee
over 11 years ago
Hi, Raghu. A couple things.
If the table name is different from the CDT name, add an @Table(name = "<tableName>").
If any CDT field names are different from the table column names, add an @Column(name = "<tableColumnName>").
If one of your CDT fields should be a primary key, add an @Id annotation to that field in the CDT.
If your primary key should be autogenerated, add an @GeneratedValue annotation that that field in the CDT.
Hope this helps!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Reject Answer
Cancel
0
colton.beck
Appian Employee
over 11 years ago
Also, after you create the CDT and add it to a data store, click 'Verify.' If everything is ok, it should verify correctly and not require another table to be added before you can 'Save and Publish' the data store.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
+1
colton.beck
Appian Employee
over 11 years ago
Here's an example of how you would use each of these:
<xsd:complexType name="Test_Data_Type">
<xsd:annotation>
<xsd:appinfo source="appian.jpa">
@Table(name="testdatatype")
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="tdtId" type="xsd:int" nillable="true" >
<xsd:annotation>
<xsd:appinfo source="appian.jpa">
@Id
@GeneratedValue
@Column(name="test_datatype")
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Reject Answer
Cancel
0
rajesh kilaru
over 6 years ago
in reply to
colton.beck
[deleted]
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
ankita0004
A Score Level 1
over 6 years ago
in reply to
rajesh kilaru
Can you check the datasource in datastore I think you created the view in different database and now trying to map this on different database
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Reject Answer
Cancel
0
rajesh kilaru
over 6 years ago
in reply to
ankita0004
both are same i have a question here
<xsd:schema xmlns:xsd="
www.w3.org/.../XMLSchema"
xmlns:tns="urn:com:appian:types" targetNamespace="urn:com:appian:types">
do we need to change this or it's just be like that .
Thank you!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
ankita0004
A Score Level 1
over 6 years ago
You have put a primary key in it by @Id annotation
and the database view will have atleast 1 non null unique column
<xsd:schema xmlns:xsd="
www.w3.org/.../XMLSchema"
xmlns:tns="urn:com:appian:types:MP" targetNamespace="urn:com:appian:types:MP">
<xsd:complexType name="Test">
<xsd:annotation>
<xsd:appinfo source="appian.jpa">
@Table(name="Test")
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="Id" nillable="true" type="xsd:int">
<xsd:annotation>
<xsd:appinfo source="appian.jpa">@Id @Column(name="Id", columnDefinition="int")</xsd:appinfo>
</xsd:annotation>
</xsd:element>
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Reject Answer
Cancel
0
rajesh kilaru
over 6 years ago
in reply to
ankita0004
when i download thw xcript intrestingly it was altering the existing view but i check my XSD it was having all the fields.
Thanks !
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Puspendu Pal
over 6 years ago
in reply to
rajesh kilaru
Hello,
From XSD prospective there is no difference between a table and a view. As long as the table/view name , the columns along with the primary key exists in the DB as defined in the XSD, the system will not need to create a new table.
Please double check the values .
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>