Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.2
Mapping documents: refer to Java persistence with Hibernate
Code between sessionFactory.openSession() and session.close():
The following code is from "Java persistence with Hibernate" book, page 684.
Code:
session.createSQLQuery("select {i.*}, {u.*} from ITEM i" +
" join USERS u on i.SELLER_ID = u.USER_ID " +
" where u.USERNAME = :uname")
.addEntity("i", Item.class)
.addJoin("u", "i.seller")
.setParameter("uname", "johndoe");
The code returns List<Object[]>, and each Object[] has two element - Item and User.
But as you see, the user is actually item.seller.
Why don't hibernate return just Item object which already include seller object?
What should I do for getting List<Item> object and each Item object include seller object?