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 7776169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:48:44+00:00 2026-06-01T17:48:44+00:00

I have gone through many videos and tutorials explaining about how to configure one

  • 0

I have gone through many videos and tutorials explaining about how to configure one to many relation in hibernate using annotation mechanism. Still I am getting this error.

the error is :
org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: bean.Professor.coursesAssigned[bean.Course]
Use of @OneToMany or @ManyToMany targeting an unmapped class: bean.Professor.coursesAssigned[bean.Course]

My classes are :

Professor.java

    package bean;

    import java.util.Set;

    import javax.persistence.CascadeType;
    import javax.persistence.Entity;
    import javax.persistence.FetchType;
    import javax.persistence.OneToMany;

    @Entity
    public class Professor extends User{

        @OneToMany(targetEntity = Course.class, mappedBy = "assignedProfessor", 
                cascade = CascadeType.ALL , fetch = FetchType.LAZY)
        private Set<Course> coursesAssigned;
    }

and course.java is :

    package bean;

    import javax.persistence.JoinColumn;
    import javax.persistence.ManyToOne;

    public class Course {

        private Integer courseId;
        private String courseName;

        @ManyToOne(targetEntity = Professor.class)
        @JoinColumn(name = "professor_join")
        private Professor assignedProfessor;
    }
  • 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-01T17:48:46+00:00Added an answer on June 1, 2026 at 5:48 pm
    org.hibernate.AnnotationException: 
    Use of @OneToMany or @ManyToMany targeting an unmapped class: bean.Professor.coursesAssigned[bean.Course] 
    Use of @OneToMany or @ManyToMany targeting an unmapped class: bean.Professor.coursesAssigned[bean.Course]
    

    The exception has already explained the causes . @OneToMany and @ManyToMany can only be annotated on the property whose class is a mapped class. A class is considered as mapped if they are annotated with @Entity and is included as <mapping class> in the configuration file or programmatically included in the Configuration instance.

    So , I believe the exception will be gone after you mark @Entity on the class Course.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have gone through the tutorials of using network resources in android. But I
While attempting to build a website, i have gone through many online tutorials. Thanks
I have gone through many articles but I am still not clear about the
How can I add scrollbar to the subplots? I have gone through many tutorials
I want to translate text in Indian languages. I have gone through many articles
Have gone through hibernate api specification on FlushMode but didn't get the exact difference.
I have gone through many links on this site and others but I could
I have already installed and worked template which has gone through many changes as
I have gone through many related SO threads and got some basic info. Already
I have gone through many post but did not got any clear answer. I

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.