Search code examples
javas4sdk

Error when trying to retrieve BusinessPartnerUUID


I've followed this deep dive blog 12. Deep Dive 12 It ran okay. And I am more interested in BusinessPartnerUUID, so I modify the file service-model.cds.

using API_BUSINESS_PARTNER as bp from './external/csn/API_BUSINESS_PARTNER';

service CrudService{

 @cds.persistence.skip
 Entity BusinessPartner as projection on bp.A_BusinessPartnerType{
   BusinessPartner,
   LastName,
   FirstName,
   BusinessPartnerCategory,
   BusinessPartnerUUID
  };
}

However, when I run this time, the service returns

The type 'class java.lang.String' of the value object is not supported.

As I do some googling, it leads me to this method Method internalValueToString

This is handled by the application programming model What can I do in this case to resolving the error? Thanks


Solution

  • I could reproduce your issue. It appears that the used Olingo lib has a problem with the type conversion of the UUID field. However I am not sure yet what causes the problem.

    For the moment you can do the following:

    Adjust the service definition by referring to a custom Business Partner entity definition instead. This is the same approach as in Step 3. of the Deep Dive.

    service.cds:

    using my.app from '../db/data-model';
    
    service CrudService {
     @cds.persistence.skip
     entity BusinessPartner as projection on bookshop.BusinessPartners;
    }
    

    data-model.cds

    entity BusinessPartners {
     key BusinessPartner : String(10);
     LastName: String(40);
     FirstName: String(40);
     BusinessPartnerUUID: String(36);
    }
    

    The UUID Field is of type CDS UUID and translates to OData EDM UUID field -> String(36).

    Hope this was helpful.