shynate26 wrote:
Yes it is possible !! If you are using the HQL navigate the reference object to identifier.
Say a Person has n number of Address. Here Person -< Address (1-many)
now List<Long> addressIds = session.createQuery("sample","select add.id from Person p,
Address A where a.person_id=p.id").list();
Hope this resolves your problem!!
Not exactly. What I meant was I don't want to create a special query. Here's a sample code:
Session s = SessionFactory.openSession();
Person p = s.get(1234);
for (Address a : p.getAddresses()) {
print(a.getId()); // normally, all addresses related to the person will be fetched here and loaded into the collection.
// I want to only load the Id's at this point and minimize the amount of data that is transferred from DB to application.
print(a.getStreetName()); // This is where I would like to load the entire address collection or this address object.
}