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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:05:21+00:00 2026-06-09T20:05:21+00:00

I am doing a simple Poll system. I have 2 tables: Person : ID,

  • 0

I am doing a simple Poll system. I have 2 tables:

Person: ID, Name, Surname

Vote: ID, Vote (Boolean), VoterID (This is actually FK_PersonID), PersonID (This is actually FK_PersonID as well).

I need to be able to identify who cast the vote as well as who the vote was for – using the people stored in the Person table for both of these needs. The table Person contains user details of people that can “Vote” as well as be “Voted for”. People are allowed to decide whether they want to vote for themselves or not.

I’ve mapped out my tables in my domain objects like this:

Person

    private Integer ID;
    private String name;
    private String surname;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ID")
    public Integer getID() {
        return ID;
    }

    public void setID(Integer ID) {
        this.ID = ID;
    }

    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "surname")
    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

Vote

private Integer ID;
private Person voter;
private Person person;
private Boolean vote;

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
public Integer getID() {
    return ID;
}

public void setID(Integer ID) {
    this.ID = ID;
}

@Column(name = "vote")
   public Boolean getVote() {
    return vote;
}

public void setVote(Boolean vote) {
    this.vote = vote;
}

@ManyToOne
@JoinColumn(name = "personID")
public Person getVoter() {
    return voter;
}

public void setVoter(Person voter) {
    this.voter = voter;
}

@ManyToOne
@JoinColumn(name = "personID")
public Person getPerson() {
    return person;
}

public void setPerson(Person person) {
    this.person = person;
}

Error message

Caused by: org.hibernate.MappingException: Repeated column in mapping
for entity: web.poll.domain.Vote column: personID (should be mapped
with insert=”false” update=”false”)

  • 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-09T20:05:22+00:00Added an answer on June 9, 2026 at 8:05 pm

    You use the same @JoinColumn for voter and person. Change to @JoinColumn("personID") for associated person and @JoinColumn("voterID") for associated voter and all should be fine.

    As a side note because you tagged this with domain-driven-design… Your vote class would be more DDD style if implemented like this:

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ID")
    private Integer ID;
    
    @ManyToOne
    @JoinColumn(name = "voterID")
    private Person voter;
    
    @ManyToOne
    @JoinColumn(name = "votedForID")
    private Person votedFor;
    
    @Column(name = "vote")
    private Boolean vote;
    
    public void cast(Person voter, Person votedFor, boolean vote) {
        // Maybe assert that this vote has not already been casted
        this.voter = voter;
        this.votedFor = votedFor;
        this.vote = vote;
    }
    
    public Integer getID() {
        return ID;
    }
    
    public Boolean isUpVote() {
        return vote;
    }
    
    public Boolean isDownVote() {
        return !vote;
    }
    
    public Person getVoter() {
        return voter;
    }
    
    public Person getVotedFor() {
        return votedFor;
    }
    

    Just an example, don’t know if I got the meaning of your vote boolean right to indicate an up/down vote.

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

Sidebar

Related Questions

I've been doing simple multi-threading in VB.NET for a while, and have just gotten
I have a WCF service hosted in IIS6. It is doing simple WebRequest. When
on my master page, I have referenced jquery file. I am doing simple hover
I am doing simple formatting for an email with StringBuilder and have code that
I'm quite new to vb and doing simple basics, I have managed to access
I have a simple poll site. I would like to disallow possibility of voting
I'm doing a simple chat script and I have the killSession function which kills
i have been doing simple MVC tutorials for a while and i get the
I was doing simple things with hibernate, as I have to learn it for
I have a jQuery UI which is doing simple autocomplete function. Autocomplete is coming

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.