Hi All, Here is my situation for writing xsd's had 3 c

Hi All,

Here is my situation for writing xsd's

had 3 cdt's

1. client - xsd created - table created
2. employee - xsd created - table created

3. pay

in this pay cdt PK of client and PK of employee are the foreign keys and they are mapped with "many to one" relationship with those 2 (means many records in pay can have single client or employee )

I already have referred forum.appian.com/.../Defining_a_Custom_Data_Type

and written xsd for pay with following annotations.

<?xml version="1.0" encoding="utf-8" ?>
<xsd:schema xmlns="urn:appian:example:assocations:many-to-one" elementFormDefault="qualified" targetNamespace="urn:appian:example:assocations:many-to-one" xmlns:xsd="www.w3.org/.../XMLSchema">

<xsd:complexType name="pay">
--
<xsd:element minOccurs="0" nillable="false" maxOccurs="unbounded" name="clientId" type="client">
<xsd:annotation>
<xsd:appinfo source="appian.jpa">
@ManyToOne
                     ...

OriginalPostID-77431

OriginalPostID-77431

  Discussion posts and replies are publicly visible

Parents
  • @Sarat, If there is no relationship for 'clientidinteger','employeeidinteger' columns in 'pay' with 'client' and 'emp', then setting of nillable(in element) or nullable(in @Column) to false could have worked fine. But here you are trying to establish a relationship, particularly many-many and what you want is, this relationship should be mandatory i.e. 'clientidinteger' and 'employeeidinteger' shouldn't be null. So refer to @ManyToOne annotation. It has an parameter 'optional'. This defaults to true if you don't set it. Set this to true, and a non-null relationship will be established.
    Try with the following XSD:





    @Table(name="pay")






    @ManyToOne(optional=false)
    @JoinColumn(name="clientidinteger", unique=true)



    \t


    @ManyToOne(optional=false)
    \t@JoinColumn(name="employeeidinteger", unique=true)




    \t


    ---


    \t--


    Note: This isn't tested as I don't have access to apian today. Let me know whether it is working fine and if you still have any concerns. Also go through the following link and have a look at section-9 which gives you a clear idea of using annotations : http://download.oracle.com/otn-pub/jcp/ejb-3_0-fr-eval-oth-JSpec/ejb-3_0-fr-spec-persistence.pdf
Reply
  • @Sarat, If there is no relationship for 'clientidinteger','employeeidinteger' columns in 'pay' with 'client' and 'emp', then setting of nillable(in element) or nullable(in @Column) to false could have worked fine. But here you are trying to establish a relationship, particularly many-many and what you want is, this relationship should be mandatory i.e. 'clientidinteger' and 'employeeidinteger' shouldn't be null. So refer to @ManyToOne annotation. It has an parameter 'optional'. This defaults to true if you don't set it. Set this to true, and a non-null relationship will be established.
    Try with the following XSD:





    @Table(name="pay")






    @ManyToOne(optional=false)
    @JoinColumn(name="clientidinteger", unique=true)



    \t


    @ManyToOne(optional=false)
    \t@JoinColumn(name="employeeidinteger", unique=true)




    \t


    ---


    \t--


    Note: This isn't tested as I don't have access to apian today. Let me know whether it is working fine and if you still have any concerns. Also go through the following link and have a look at section-9 which gives you a clear idea of using annotations : http://download.oracle.com/otn-pub/jcp/ejb-3_0-fr-eval-oth-JSpec/ejb-3_0-fr-spec-persistence.pdf
Children
No Data