Deploy Playframework application on Heroku - using ClearDB(MySQL)
在JPA中,將createNativeQuery的結果轉換成其他物件
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Query q = JPA.em().createNativeQuery("SELECT * from post p"); | |
List<Post> posts = (List<Post>)q.getResultList(); |
但是當你執行時,會出現無法轉換的錯誤:ClassCastException occured : [Ljava.lang.Object; cannot be cast to models.Post