[hibernate-users] sql error with criteria query

Genís Pujol gpujol at ngeografics.com
Thu Jun 3 09:51:03 EDT 2010


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



More information about the hibernate-users mailing list