开发者

JPA Hibernate Help!

I have just studied about JPA. And I had created a simple program which return the query "SELECT ...". Unfortunately, I always get an exception like

java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to application.Model
   at application.Main.main(Main.java:33)

I can't understand why, yet I tried using String.valueOf(...) to the line and returns the same exception.

开发者_开发知识库

All of the codes are present here.


Instead of

Query query = entityManager.createNativeQuery("SELECT * FROM person");
List<Model> models = query.getResultList(); 

You can try -

List<Model> models = entityManager.createQuery("from Model",Model.class).getResultList();

I don't see any purpose for using native query here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜