This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Hibernate Many-to-One mapping  RSS feed

Ranch Hand
Posts: 114
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
I am having trouble implementing Many-to-one mapping in hibernate. I have the done the following:
I have a table called Users and another table called Rank. The relationship between the two is that many users can have the same rank. So it is Many-to-One mapping. The Users and Rank tables are as follows:

The mapping files are as follows:

I am using hibernate template to insert the values in the Users table. The rank is a combobox item in the registration form. Each rank has an ID associated with it which has to be inserted in the users table's 'rankid' column.
The code for this is as follows:

My Form Controller is as follows:

When ever i try to register a new user, it is not calling the form controller. Am I doing something wrong?
Please help.
Thank you.
Posts: 1682
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At this point it is not an ORM problem it is a Spring / JSP problem. You have a form and when you submit that form you are not getting inside your controller.

Here are my suggestions:

1. Forget about hibernate altogether you are not even getting far enough to have issues with that yet. When you do get to it do not use HIbernateTemplate. The use of this is deprecated, and is no longer needed. See the Spring reference manual for the modern way using the standard API's rather than a template.
2. Do not use SimpleFormController this also is old and deprecated. Use the modern controller style and the newest version of Spring.

Start with updating your Spring (if needed) and your controllers and get that piece working. If you need more help with that then post in our Spring forum. This link will get you started if you need an example: (source code)
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!