CDT(Custom data type), purpose of CDT and were should we use CDT?

Hi,

Could any of you explain me what is CDT, why do we use CDT and when can we use it?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi tanveera0001

    It's a structure which represents a logical grouping of related data/attributes/properties.

    Example: Address CDT which has some related attributes such as line1 Address, line2 Address, address Type etc.. similarly whenever you get such requirement, we need to go for CDT.

    CDT is similar to a Persistence Class in JPA/Hibernate which is being used in Java to interact with the Database.

    Benefit and usage of CDT

    • Lets's assume you want to capture various attributes of employee such as fName, lName, email etc.. if you do not opt for CDT then we need to defines at least 1 variable for each component and this will add difficulties in managing the data, and identifying which attribute is logically grouping with the other one.
    • If you do not opt for CDT then you will need to use Native SQL to perform any operation on DB such as Query, Update, Insert, Delete etc..
    • If we depend upon Native SQL then we need to re-write the expressions whenever we shuffle from one DB Vendors to another (such as MySQL to Oracle) as we know that, Native SQL differs from One vendor to another. Hence this adds an additional maintenance and in this case you will not be able to utilize the feature of JPA (migrates the query based on the mapped DB vendor)
    • If you do not have a CDT then you cannot build an Entity Backed Record, instead you will need to go for Expression Backed Record with Native SQL which is never a recommended approach

    Similarly there are several other reasons why we need to go for CDT. And as per my understanding, in most of the use-cases we should go for CDT.

    Hope this will help.

Reply
  • 0
    Certified Lead Developer

    Hi tanveera0001

    It's a structure which represents a logical grouping of related data/attributes/properties.

    Example: Address CDT which has some related attributes such as line1 Address, line2 Address, address Type etc.. similarly whenever you get such requirement, we need to go for CDT.

    CDT is similar to a Persistence Class in JPA/Hibernate which is being used in Java to interact with the Database.

    Benefit and usage of CDT

    • Lets's assume you want to capture various attributes of employee such as fName, lName, email etc.. if you do not opt for CDT then we need to defines at least 1 variable for each component and this will add difficulties in managing the data, and identifying which attribute is logically grouping with the other one.
    • If you do not opt for CDT then you will need to use Native SQL to perform any operation on DB such as Query, Update, Insert, Delete etc..
    • If we depend upon Native SQL then we need to re-write the expressions whenever we shuffle from one DB Vendors to another (such as MySQL to Oracle) as we know that, Native SQL differs from One vendor to another. Hence this adds an additional maintenance and in this case you will not be able to utilize the feature of JPA (migrates the query based on the mapped DB vendor)
    • If you do not have a CDT then you cannot build an Entity Backed Record, instead you will need to go for Expression Backed Record with Native SQL which is never a recommended approach

    Similarly there are several other reasons why we need to go for CDT. And as per my understanding, in most of the use-cases we should go for CDT.

    Hope this will help.

Children
No Data