Hibernate: could not locate named parameter

Today I got this exception. Pretty obvious? Well, no. The named parameter IS there. (Sidenote: this exception generally means that when trying to call setParameter(..) with a certain param name, that name is not found in the query, in the form :paramName)
The query is generated dynamically on different entities. And it works, except for one.
And that “one” turned out NOT to be an @Entity. But Hibernate wasn’t too helpful on that.

So to summarize, when you attempt to make a query on a non-entity, Hibernate will not complain that it is not an entity – it will complain about other things.

Advertisements

4 Responses to “Hibernate: could not locate named parameter”

  1. Zach Says:

    A couple of years later, and this one got me too. Thanks for the tip!

  2. connor Says:

    thanks, this helped me. Hibernate logging still sucks.

  3. bob Says:

    Thanks; I’ve been chasing the same thing all day and your post gave me the clue. I forgot to add some newly added entity classes to the hibernate config.

  4. axet Says:

    thanks! also it can fail with this magic error if you cast column as column instead of JoinColumn

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: