Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8815525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:24:07+00:00 2026-06-14T04:24:07+00:00

I am using Hibernate 3.2.5. I am getting the above exception while using many-to-one

  • 0

I am using Hibernate 3.2.5. I am getting the above exception while using many-to-one mapping. The training table is having a many to one relation with Department table, i.e. One Depatement is capable of taking more than one training.

The exception is asking me to add insert="false" update="false" in my hbm file. If I add this bit in hbm file, then the code works fine.

Here is the hbm file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>

  <class name="com.infy.model.Training" table="training">
  <id name="Id" type="integer" column="ID">
      <generator class="assigned"></generator>
  </id>      
  <property name="trainerName">
      <column name="TRAINER_NAME"></column>
  </property>
  <property name="deptId">
      <column name="DEPT_ID"></column>
  </property>
  <property name="trainingSubject">
      <column name="TRAINING_SUBJECT"></column>
  </property>
  <many-to-one name="departmentDetails" column="DEPT_ID"></many-to-one>
  </class>
</hibernate-mapping>

If I change this line to:

<many-to-one name="departmentDetails" column="DEPT_ID" insert="false" update="false"></many-to-one>

Then the code works. I want to know what is the exact reason for adding this.

Regards,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:24:08+00:00Added an answer on June 14, 2026 at 4:24 am

    You have mapped the DEPT_ID column twice, here:

      <property name="deptId">
          <column name="DEPT_ID"></column>
      </property>
    

    And here:

      <many-to-one name="departmentDetails" column="DEPT_ID"></many-to-one>
    

    When executing a select statement, Hibernate will be fine populating two properties of your object from the same column, however when doing an insert or an update it cannot decide which property to persist in the database.

    Why do you need two properties mapped to the same column in the first place? If you need access to the deptId, you can probably remove the deptId property and instead do

    training.getDepartmentDetails().getId()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting Exception while running query using Criteria API org.hibernate.QueryException: could not resolve property: com
I'm using hibernate 4 and xml based mapping. Here is the exception I'm getting
I am trying to implement a one-to-many relationship using NHibernate 2.1.2 but keep getting
I am using Hibernate and getting Exception in thread main org.hibernate.ObjectNotFoundException: No row with
I am using Hibernate 4.1 and I'm getting the following exception whenever I try
I'am using Hibernate framework 3.6.10.Final and MySql. I'am getting Exception in thread main org.hibernate.MappingException:
I'm having trouble getting Hibernate to perform a bulk insert on MySQL. I'm using
I am using Hibernate's lazy loading, and am getting sessionFactory missing exception, even after
I'm new to using Hibernate with Java. I'm getting the following exception. The stuff
i am using hibernate as ORM tool, and while loading the data from table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.