0
list.add(build.equal(bondRoot.get(Bond_.writingCompanyCode),dtlRoot.get(ArPstdDtl_.companycd ).as(String.class)));

but am getting the following error:

Caused by: org.apache.openjpa.persistence.ArgumentException: No metadata was found for type "class java.lang.String". The class is not enhanced.

Could someone help me out on this ??

Milen
  • 8,697
  • 7
  • 43
  • 57

1 Answers1

1

Changing type from BigDecimal to String needs conversion, not a cast. Method as cannot convert from type to other - it is purely for typecasting, as documented:

Perform a typecast upon the expression, returning a new expression object. This method does not cause type conversion: the runtime type is not changed. Warning: may result in a runtime failure.

Criteria API does not offer conversion from BigDecimal to String. Database vendor specific functions can be used via CriteriaBuilder.function.

Mikko Maunu
  • 41,366
  • 10
  • 132
  • 135