-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Using Fetching strategy in one-to-many ?
PostPosted: Wed Jul 08, 2009 12:40 pm 
Newbie

Joined: Tue Jul 07, 2009 11:09 pm
Posts: 2
Hii all, i try to used fetching strategy in one to many relationship in hibernate, but i little confusing with it.
This my code :
Code:
public List<Album> getAll() {
        session = factory.getCurrentSession();
        transaction = session.beginTransaction();       
        List<Album> albums = session.createQuery("from Album a join fetch a.songs s where a.id=s.id  ").list();
        return albums;
    }


In this case i have a Album class and Song class. One album can have many songs or nothing.
But, If the album have not a song, it will not be fetch for me...
Any body help me please....


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.