|
@@ -29,14 +29,14 @@ public class Query4 {
|
29
|
29
|
Session session = sessionFactory.openSession();
|
30
|
30
|
try {
|
31
|
31
|
// List<Result> list = session.createQuery("select a.id as cart_id, b.id as id, b.cart as item_cart_id from Cart a, Items b where a.id = b.cart", Result.class).getResultList();
|
32
|
|
- List<Object> list = session.createQuery("select b from Cart a, Items b where a.id = b.cart", Object.class).getResultList();
|
33
|
|
- Iterator<Object> iterator = list.iterator();
|
|
32
|
+ List<Items> list = session.createQuery("select b from Cart a, Items b where a.id = b.cart", Items.class).getResultList();
|
|
33
|
+ Iterator<Items> iterator = list.iterator();
|
34
|
34
|
while(iterator.hasNext()){
|
35
|
|
- Object o = iterator.next();
|
36
|
|
- Result person = (Result) iterator.next();
|
37
|
|
- System.out.print("Cart_id: " + person.getCart_id());
|
38
|
|
- System.out.print("Id: " + person.getId());
|
39
|
|
- System.out.println("Item_cart_id: " + person.getItem_cart_id());
|
|
35
|
+ Items i = iterator.next();
|
|
36
|
+ System.out.println("id: " + i.getId());
|
|
37
|
+ System.out.println("Cart: " + i.getCart());
|
|
38
|
+ Cart c= i.getCart();
|
|
39
|
+ System.out.println(c);
|
40
|
40
|
}
|
41
|
41
|
} catch (Exception e) {
|
42
|
42
|
e.printStackTrace();
|