[hibernate-users] sql error with criteria query

Douglas Ferguson douglas at douglasferguson.us
Thu Jun 3 12:01:26 EDT 2010


Are those restrictions & projections our column names or field names? 
I believe the criteria api is similiar to HQL in that it wants you to use the field names not the database column names.

Also, what's the stack trace look like?

D/




On Jun 3, 2010, at 8:51 AM, Genís Pujol wrote:

> Hello list,
> 
> I'm getting the following error:
> 
> SQLGrammarException:  select this_.territorioCodigo as y0_, 
> this_.perfilId as y1_ from UsuarioTerritorioPerfilId this_ where 
> this_.usuarioId=?
> 
> 
> when using the following query:
> 
> List utpList = session.createCriteria(UsuarioTerritorioPerfilId.class).setProjection(
> 	    		    Projections.projectionList()
> 	    	        .add(Projections.property("territorioCodigo"))
> 	    	        .add(Projections.property("perfilId"))
> 	    	    ).add(Restrictions.eq("usuarioId",id)).list();
> 			 }catch (SQLGrammarException e) {
> 				 this.setMsg("Criteria error: No s'han pogut obtenir les dades: " + e.getSQL());
> 					return msg;
> 			 }
> 
> 
> You can check the full code here: http://dpaste.com/202714/ (mapped java 
> class) and here http://dpaste.com/202716/ (function making the query).
> 
> Any tips will be appreciated :)
> 
> Regards,
> 
> Genis
> 
> _______________________________________________
> hibernate-users mailing list
> hibernate-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-users




More information about the hibernate-users mailing list