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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:33:39+00:00 2026-06-10T00:33:39+00:00

I am creating a web application using spring and hibernate. Is it possible to

  • 0

I am creating a web application using spring and hibernate. Is it possible to have multiple @ManyToOne mappings in one table that reference the same Column in another table? What I mean is

If I have these two tables

@Entity
@Table(name="AUTHOR")
public class Author{

@Id
@GeneratedValue
@Column(name="AUTHOR_ID")   
private IntegerauthorId;

@Column(name="AUTHOR_NAME")
private String authorName;


...

}

and

@Entity
@Table(name="BOOK")
public class book{

@Id
@GeneratedValue
@Column(name="BOOK_ID")
private Integer bookId;


@Column(name="TITLE")
private String title; 

@Column(name="PREFACE_AUTHOR")
private Author prefaceAuthor;

@Column(name="BOOK_AUTHOR")
private Author bookAuthor;

...

}

How do I do the mapping so that I can populate both PREFACE_AUTHOR and BOOK_AUTHOR from the AUTHOR table?
One Author can be both the preface and book author but there can only be one preface author and one book author per book.

Let me know if there is anything I can clarify.

Thank you for the help!

/D

  • 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-10T00:33:41+00:00Added an answer on June 10, 2026 at 12:33 am

    You should specify that it is a many-to-one and use @JoinColumn instead of @Column, like this:

    @ManyToOne
    @JoinColumn(name="PREFACE_AUTHOR")
    private Author prefaceAuthor;
    
    @ManyToOne
    @JoinColumn(name="BOOK_AUTHOR")
    private Author bookAuthor;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I creating a web application using JSF,Hibernate,Spring. I have added a filter for checking
I am creating one web application using Spring and hibernate. I am little confused
I'm creating a web application using spring mvc. I have started to incorporate the
I am creating a web application using zkoss 5.0.4, Spring 3.0.3, Hibernate 3, and
I am creating web application using Spring, Hibernate, Struts, and Maven. I get the
I am creating a web application using Spring. One requirement is after processing a
I am creating a web application that will have many users. Each user has
i'm creating a very simple (hello World quality) web application using spring mvc 3.0.
I've setup a Wicket + Hibernate + Spring Web application that involves gathering some
I tried creating a small example using Spring, rest, Hibernate. In order to have

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.