-->
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.  [ 3 posts ] 
Author Message
 Post subject: Simple Hibernate query problem (bugging me for days)
PostPosted: Thu Mar 13, 2008 6:59 am 
Newbie

Joined: Thu Mar 13, 2008 6:50 am
Posts: 6
Hello everyone!

The following Hibernate problem keeps me bugging for ages.

The query itself is quite simple.

The objects are:

Clip and License.

Clip has the following method:

@ManyToMany
public Set<License> getLicenses() {
return licenses;
}


Now I want to query all clips with a specific license:

I have tried:

clipCriteria = clipCriteria.createCriteria("licenses").
createCriteria("license").add(Restrictions.eq("id", getSelectedLicense().getId()));

which returns:

could not resolve property: license of: com.company.dao.License

I have also tried:

clipCriteria = clipCriteria.createCriteria("licenses").add(Expression.eq("id", getSelectedLicense().getId()));

and:

clipCriteria = clipCriteria.createCriteria("licenses")
.createAlias("license","licenses")
.add(Restrictions.eq("license.id",getSelectedLicense().getId()));

and:

clipCriteria = clipCriteria.createCriteria("licenses")
.createAlias("licenses","license")
.add(Restrictions.eq("license.id",getSelectedLicense().getId()));

Has anyone got the right solution?

Thanks!

Toby


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 7:27 am 
Newbie

Joined: Thu Mar 13, 2008 6:50 am
Posts: 6
Or is this a Hibernate bug ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 7:33 am 
Newbie

Joined: Thu Mar 13, 2008 6:50 am
Posts: 6
The documentation on:

http://www.hibernate.org/hib_docs/reference/en/html/querycriteria.html

does not seem to have an appropriate example....as the Kittens are not a Set of Cats ?


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