aspose file tools*
The moose likes Object Relational Mapping and the fly likes about inner join and inner join fetch again Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "about inner join and inner join fetch again" Watch "about inner join and inner join fetch again" New topic
Author

about inner join and inner join fetch again

peter tong
Ranch Hand

Joined: Mar 15, 2008
Posts: 240


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?
 
Consider Paul's rocket mass heater.
 
subject: about inner join and inner join fetch again