選擇我覺得自己像一個小白試圖找出這一個 -春天的JpaTemplate語法從列表
我想知道下面的JPA查詢從號碼列表中選擇正確的語法。 ?
List<Long> personIds = new ArrayList<Long>();
personIds.add(1L);
personIds.add(2L);
jpaTemplate.find("select count(*) from Person p where p.id in (?) ",personIds);
當我嘗試,我得到
"java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.Long"
嘗試長賦值給一個列表,在投它'(對象)personIds'。 – Smit 2013-02-09 00:56:33
供參考:'JpaTemplate'已被棄用。看到這裏---> [org.springframework.orm.jpa JpaTemplate類](http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/orm/jpa/JpaTemplate .html) – Smit 2013-02-09 01:05:11
鑄造到對象沒有工作。我只需要運行這一個查詢,這是現有代碼的一部分,所以我不想更改爲更新的實現,因爲我知道我缺少一些非常微不足道的東西。 – user1959268 2013-02-09 01:12:36