Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about inner join and inner join fetch again

 
peter tong
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


the result in console is
...
[java] Hibernate: select supplier0_.id as id0_, products1_.id as id1_, supplier0_.name as name1_0_, products1_.name as name0_1_, products1_.description as descript3_0_1_, products1_.price as price0_1_, products1_.supplierId as supplierId0_1_, products1_.supplierId as supplierId__, products1_.id as id__ from Supplier supplier0_ inner join Product products1_ on supplier0_.id=products1_.supplierId
[java] Supplier Name 1 Product 1
[java] Supplier Name 1 Product 1
[java] Supplier Name 2 Product 3
[java] Hibernate: select supplier0_.id as id0_, products1_.id as id1_, supplier0_.name as name1_0_, products1_.name as name0_1_, products1_.description as descript3_0_1_, products1_.price as price0_1_, products1_.supplierId as supplierId0_1_ from Supplier supplier0_ inner join Product products1_ on supplier0_.id=products1_.supplierId
[java] Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to Supplier [java] at Main.displaySupplierList(Main.java:38)
[java] at Main.main(Main.java:24)
[java] Java Result: 1

if not using fetch, iter.next() cannot be cast to Supplier, why?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic