-->
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.  [ 4 posts ] 
Author Message
 Post subject: JPA Query help
PostPosted: Mon Jun 09, 2008 1:40 pm 
Newbie

Joined: Mon Jun 09, 2008 1:28 pm
Posts: 2
Hi

Im a new JPA user and I could use some help with a query.
I have two objects(Project and Developer) that are many to many.
So each pojo or entity has a Set of the other defined.

ie
Project Entity has
String name
ManyToMany
Set<Developer> developer ......


Developer Entity has
String name
ManyToMany
Set<Project> project

How would I create a namedquery to find all developers for a particular project name or all projects for a particular developer name?

Im having trouble with the JPQL syntax
Ive tried
query = "select a from Developer a IN(a.projects) b where b.name = rojname"

but the compiler doesnt like that.

Ive tried searching for an example of a JPA many to many query without any luck. Any help would be much appreciated!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 4:52 pm 
Newbie

Joined: Mon Jun 09, 2008 1:28 pm
Posts: 2
Problem solved on another forum

"select a from Developer a IN(a.projects) b where b.name = projname"

Should be

"select a from Developer a, IN(a.projects) b where b.name = projname"


missing comma..ugh!
thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 23, 2008 11:19 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Sweet! Thanks for the update!

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 27, 2008 12:58 pm 
Newbie

Joined: Fri Jun 27, 2008 12:44 pm
Posts: 4
The JPA means what?
who can tell me, I'm a little confused

_________________
MSN/Email: electronics-mac-sony@hotmail.com
http://www.electronics-mac-sony.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.