|
|
|
Re: [Hibernate] HQL statement for one-to-many [message #685080 is a reply to message #683501] |
Thu, 16 June 2011 19:16 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Here the answer I gave earlier but which disappeared in the void (there are apparently problems with the newsgroup/forum to sync up):
I think you should make this a join to the MobileProvider entity (assuming that's the name), and use the special elements function, something like this:
select count(asset.ID) from Asset as asset, MobileProvider as mp where mp in elements(asset.StateInfo) and mp.Name='Vodafone'
Hibernate/HQL has some nice collection functions which you can use in the where clause.
gr. Martin
[Updated on: Thu, 16 June 2011 19:16] Report message to a moderator
|
|
|
|
Re: [Hibernate] HQL statement for one-to-many [message #685236 is a reply to message #685183] |
Fri, 17 June 2011 05:01 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
I have not tried it but see this part of the HQL chapter in the Hibernate docs:
HQL functions that take collection-valued path expressions: size(), minelement(), maxelement(), minindex(), maxindex(), along with the special elements() and indices functions that can be quantified using some, all, exists, any, in.
you can try maxelement I guess in the whereclause:
select count(asset.ID) from Asset as asset, MobileProvider as mp where mp = maxelement(asset.StateInfo) and mp.Name='Vodafone'
Can you let me know if this works (cause then I know it to)?
gr. Martin
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04548 seconds