我已将所有表中的PK从int ID更改为UUID(VARCHAR),但之后无法执行此查询。
String HQLselect = "from Person person " +
"left join fetch person.researchGroups "+
"left join fetch person.personOptParamVals paramVal "+
"left join fetch paramVal.personOptParamDef paramDef "+
"where person.personId = :id";
Person foundUser = (Person) getHibernateTemplate().findByNamedParam(HQLselect, "id", id);
错误是:
Exception in thread "AWT-EventQueue-0" org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; SQL [select person0_.PERSON_ID as PERSON1_32_0_, researchgr1_.RESEARCH_GROUP_ID as RESEARCH1_40_1_, personoptp2_.PERSON_OPT_PARAM_DEF_ID as PERSON1_36_2_, personoptp2_.PERSON_ID as PERSON2_36_2_, personoptp3_.PERSON_OPT_PARAM_DEF_ID as PERSON1_34_3_, person0_.AUTHENTICATION as AUTHENTI2_32_0_, person0_.AUTHORITY as AUTHORITY32_0_, person0_.CONFIRMED as CONFIRMED32_0_, person0_.DATE_OF_BIRTH as DATE5_32_0_, person0_.DEFAULT_GROUP_ID as DEFAULT17_32_0_, person0_.EDUCATION_LEVEL_ID as EDUCATION18_32_0_, person0_.EMAIL as EMAIL32_0_, person0_.FB_UID as FB7_32_0_, person0_.GENDER as GENDER32_0_, person0_.GIVENNAME as GIVENNAME32_0_, person0_.LATERALITY as LATERALITY32_0_, person0_.NOTE as NOTE32_0_, person0_.PASSWORD as PASSWORD32_0_, person0_.PHONE_NUMBER as PHONE13_32_0_, person0_.REGISTRATION_DATE as REGISTR14_32_0_, person0_.SURNAME as SURNAME32_0_, person0_.USERNAME as USERNAME32_0_, researchgr1_.DESCRIPTION as DESCRIPT2_40_1_, researchgr1_.PAID_ACCOUNT as PAID3_40_1_, researchgr1_.OWNER_ID as OWNER5_40_1_, researchgr1_.TITLE as TITLE40_1_, researchgr1_.OWNER_ID as OWNER5_32_0__, researchgr1_.RESEARCH_GROUP_ID as RESEARCH1_0__, personoptp2_.PARAM_VALUE as PARAM3_36_2_, personoptp2_.PERSON_ID as PERSON2_32_1__, personoptp2_.PERSON_OPT_PARAM_DEF_ID as PERSON1_1__, personoptp2_.PERSON_ID as PERSON2_1__, personoptp3_.IS_DEFAULT as IS2_34_3_, personoptp3_.PARAM_DATA_TYPE as PARAM3_34_3_, personoptp3_.PARAM_NAME as PARAM4_34_3_ from PERSON person0_ left outer join RESEARCH_GROUP researchgr1_ on person0_.PERSON_ID=researchgr1_.OWNER_ID left outer join PERSON_OPT_PARAM_VAL personoptp2_ on person0_.PERSON_ID=personoptp2_.PERSON_ID left outer join PERSON_OPT_PARAM_DEF personoptp3_ on personoptp2_.PERSON_OPT_PARAM_DEF_ID=personoptp3_.PERSON_OPT_PARAM_DEF_ID where person0_.PERSON_ID=?]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
Caused by: ERROR 42818: Comparisons between 'INTEGER' and 'VARCHAR (UCS_BASIC)' are not supported. Types must be comparable. String types must also have matching collation. If collation does not match, a possible solution is to cast operands to force them to the default collation (e.g. SELECT tablename FROM sys.systables WHERE CAST(tablename AS VARCHAR(128)) = 'T1')
我尝试使用' ',但它没有改变任何东西。我该如何解决?谢谢。