Bill Rosmus
Bill Rosmus

Reputation: 3011

JPA Hibernate createNativeQuery throwing up with setParameter

Here is the query (I've formatted it to read more easily by humans :)

Query q = em.createNativeQuery("select group_name 
                                from groups g 
                                join credentials_groups_lu cgl on 
                                g.group_id = cgl.group_id 
                                and g.parent_id = cgl.parent_id 
                                where cgl.credential_id  = :credentialId");
q.setParameter("credentialID", credentialId);

When it gets to the set parameter line, it pukes. I read somewhere hibernate doesn't like nameNativeQueries. Is this part of the same problem? If so, how to get around it.

Thanks in advance to those with the answer. :) I don't want to sound grumpy, but I am not looking to learn how to do it using "pure" ORM. I can can do that. I need to figure out how to do this.

Upvotes: 0

Views: 625

Answers (1)

Adrian Shum
Adrian Shum

Reputation: 40056

I think it may be caused by the parameter name in your SQL and key used in setParameter, one is credentialId and the other is credentialID ( Id vs ID)

Upvotes: 1

Related Questions