This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Queries and Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Queries and "column not found" error" Watch "Queries and "column not found" error" New topic

Queries and "column not found" error

Karsten Wutzke
Ranch Hand

Joined: Jul 20, 2010
Posts: 106

I'm really having a hard time getting a DB design to work with Hibernate. I have several kinds of composite keys and some IDs as well, but nearly anything that could be considered exotic. The latest strangeness of Hibernate producing an error on the native query:

Hibernate chokes with an error that appears to be completely unrelated (there's only a multi-column many-to-one association in PlayerStats):

Somehow Hibernate seems to be expecting a column here, but again the association is multi-column. Regarding this issue I stumbled across:

A paragraph here reads:

If the entity is mapped with a many-to-one to another entity it is required to also return this when performing the native query, otherwise a database specific "column not found" error will occur. The additional columns will automatically be returned when using the * notation...

Well, this is nice to know, but how do you avoid this error?

Here's the design:
Please have a look at the PlayerStats table being connected to two other tables via a composite key of composite keys. Here's its class:

I have no idea what Hibernate is doing here. I really need some help on this.


OCJP JavaSE 6 (86%)
I agree. Here's the link:
subject: Queries and "column not found" error
It's not a secret anymore!