誰能告訴我,這是爲什麼不工作:JPA LIKE運算整數
criteria.add(cb.like((myentity.<Integer>get("integerid")).as(String.class), "2%"))
我收到以下錯誤:
The object [2%], of class [class java.lang.String], from mapping [org.eclipse.persistence.mappings.DirectToFieldMapping[integerid-->MYENTITY.INTEGERID]] with descriptor [RelationalDescriptor(org.example.model.MyEntity --> [DatabaseTable(MYENTITY)])], could not be converted to [class java.lang.Integer]
是對myinteger
屬性更改爲一個唯一的解決辦法字符串在模型中,以便我可以使用like
運算符?
BR
非常感謝。我正在測試德比數據庫。所以我會用我們的生產數據庫(postgres)來檢查它。 – reen 2011-04-05 05:31:57