I am an unfortunate dev that needs to work with a very legacy database. The problem is, that the database contains custom datatypes:
CREATE DISTINCT TYPE SCHEMA.T_STUPID_ID AS
SMALLINT WITH COMPARISONS
;
So I cannot change that, but need to get the data and query it. It appears that it does not work, cause when querying by Id (findOne) using spring data jpa (repository) I get the following error:
DB2 SQL Error: SQLCODE=-401, SQLSTATE=42818, SQLERRMC==, DRIVER=4.19.26
which is : THE DATA TYPES OF THE OPERANDS OF AN OPERATION ARE NOT COMPATIBLE So it sounds like the queries do not work with custom types :/
I also tried this way:
@Query("select p from ImSickOfThisEntity p where cast(p.entityId as integer)
= ?1 ")
But I got:
DB2 SQL Error: SQLCODE=-461, SQLSTATE=42846, SQLERRMC=IPSDBO.T_PRODUCT_ID;SYSIBM.INTEGER
which translates to :
A VALUE WITH DATA TYPE source-data-type CANNOT BE CAST TO TYPE target-data-type
How to deal with such custom types? Google is not helpful, I can only find custom Java types with standard database column types....