This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes JPA/Hibernate entity mapping error? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPA/Hibernate entity mapping error?" Watch "JPA/Hibernate entity mapping error?" New topic

JPA/Hibernate entity mapping error?

Vladimir Kroupa

Joined: Dec 26, 2008
Posts: 28
I'm using JPA with Hibernate 3.5.6 as the persistence provider. I've mapped some entities using JPA annotations and I'm using database schema generated by Hibernate, but I'm encountering incorrect SQL insert statements in runtime when trying to persist on of the entities.
Here are the entitites:

The Player entity looks like this:

The schema generated by Hibernate looks like this:

When I try to persist the MatchEntity, one of the generated insert statements is incorrect. Table Game_Player has three columns, not two.

Does anyone have an idea what could be wrong? I don't think that the interface types are causing the problems, I have the target entities specified and I tried to get rid of the interface types and the problem didn't go away.
I'll be grateful for any tips.
Vladimir Kroupa

Joined: Dec 26, 2008
Posts: 28
I can now confirm that this is not Hibernate specific. I tried swapping Hibernate for OpenJPA. The insert statement generated when trying to persist the MatchEntity has the same problem:

It has to be a problem with JPA mapping. But it still don't see where
Vladimir Kroupa

Joined: Dec 26, 2008
Posts: 28
If you would like to see the problem for yourself, you can checkout my Maven project from I'm using hsqldb and Maven Jetty plugin, so you won't have to configure anything. Just use the jetty:run goal.
If you are using an OS that doesn't have the /tmp directory, you might want to change the DataSource url property in the dao.xml Spring configuration file.

Thanks to anyone who donates his time!
I agree. Here's the link:
subject: JPA/Hibernate entity mapping error?
Similar Threads
Enumeration mapping doesn't work in JPA
JOINED strategy not sufficient?
Add constraints to table with Hibernate.
EJB - Everything works except persist()
JPA problem: org.hibernate.MappingException: Repeated column in mapping for entity