-->
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: Problem with HQL query (SOLVED)
PostPosted: Fri Jun 11, 2010 3:20 am 
Newbie

Joined: Wed Oct 07, 2009 7:34 am
Posts: 12
Hi!

I have something like this:

Code:
@Entity
@Table(name = "fp_Franquiciador")
public class Franquiciador extends com.fplus.portal.model.Entity implements Serializable {

......

   @OneToMany(mappedBy = "franquiciador", cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
   private List<SinonimoFranquiciador> sinonimosFranquiciador;
..........
}


And i'm tryin to use this hql query:

Select fran.id, fran.fecha, fran.sinonimosFranquiciador.size* From Franquiciador fran

I know fran.sinonimosFranquiciador.size* doesnt work... how can I do it??


Last edited by wiji on Fri Jun 11, 2010 5:33 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Problem with HQL query
PostPosted: Fri Jun 11, 2010 4:02 am 
Beginner
Beginner

Joined: Thu Feb 08, 2007 10:40 am
Posts: 46
The function you need is documented here:
http://docs.jboss.org/hibernate/stable/ ... xpressions

The HQL for your example needs to look like this:

Code:
Select fran.id, fran.fecha, size(fran.sinonimosFranquiciador)  From Franquiciador fran


Top
 Profile  
 
 Post subject: Re: Problem with HQL query
PostPosted: Fri Jun 11, 2010 5:25 am 
Newbie

Joined: Wed Oct 07, 2009 7:34 am
Posts: 12
Thanks you very much, problem solved!!!
Finlly i use this:

"SELECT con.id,con.titular,SIZE(icons.id) FROM Contenido con

LEFT JOIN con.imagenesContenido icons GROUP BY con"

I need to gruop by con, because it only obtained 1 results if dont grouping


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.