-->
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.  [ 2 posts ] 
Author Message
 Post subject: Create Hibernate Query for many-to-many
PostPosted: Sun Apr 16, 2006 3:57 am 
Newbie

Joined: Thu Mar 02, 2006 10:02 am
Posts: 6
Its a simple question, I'm sure. I just not so familiar with db queries.

I have the following classes:

class SRLG
{
Long id;
Collection<Link> links

@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
Collection<Link> getLinks()
}

class Link
{
Long id;
String name;
}

I want to create a hibernate query that return all the SRLGs that contain a certain link. (I got the link ID).
What would be the best way to do this?

Thanks,

Eyal Adi


Top
 Profile  
 
 Post subject: Found the solution. Very easy.
PostPosted: Sun Apr 16, 2006 8:47 am 
Newbie

Joined: Thu Mar 02, 2006 10:02 am
Posts: 6
Query query = entityManager.createQuery("from Srlg srlg where srlg.links.id = :id");


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

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.