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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:41:39+00:00 2026-05-18T06:41:39+00:00

Consider the following table: CREATE TABLE Participations ( roster_id INTEGER NOT NULL, round_id INTEGER

  • 0

Consider the following table:

CREATE TABLE Participations
(
  roster_id INTEGER NOT NULL,
  round_id INTEGER NOT NULL,
  ordinal_nbr SMALLINT NOT NULL ,
  was_withdrawn BOOLEAN NOT NULL,
  PRIMARY KEY (roster_id, round_id, ordinal_nbr),
  CONSTRAINT participations_rosters_fk FOREIGN KEY (roster_id) REFERENCES Rosters (id),
  CONSTRAINT participations_groups_fk FOREIGN KEY (round_id, ordinal_nbr) REFERENCES Groups (round_id , ordinal_nbr)
)

Here the JPA 1.0 @IdClass entity class:

@Entity
@Table(name = "Participations")
@IdClass(value = ParticipationId.class)
public class Participation implements Serializable
{
    @Id
    @Column(name = "roster_id", insertable = false, updatable = false)
    private Integer rosterId;

    @Id
    @Column(name = "round_id", insertable = false, updatable = false)
    private Integer roundId;

    @Id
    @Column(name = "ordinal_nbr", insertable = false, updatable = false)
    private Integer ordinalNbr;

    @Column(name = "was_withdrawn")
    private Boolean wasWithdrawn;

    @ManyToOne
    @JoinColumn(name = "roster_id", referencedColumnName = "id")
    private Roster roster = null;

    @ManyToOne
    @JoinColumns(value = {@JoinColumn(name = "round_id", referencedColumnName = "round_id"), @JoinColumn(name = "ordinal_nbr", referencedColumnName = "ordinal_nbr")})
    private Group group = null;

    public Participation()
    {
    }

    public Integer getRosterId()
    {
        return rosterId;
    }

    public void setRosterId(Integer rosterId)
    {
        this.rosterId = rosterId;
    }

    public Integer getRoundId()
    {
        return roundId;
    }

    public void setRoundId(Integer roundId)
    {
        this.roundId = roundId;
    }

    public Integer getOrdinalNbr()
    {
        return ordinalNbr;
    }

    public void setOrdinalNbr(Integer ordinalNbr)
    {
        this.ordinalNbr = ordinalNbr;
    }

    public Boolean getWasWithdrawn()
    {
        return wasWithdrawn;
    }

    public void setWasWithdrawn(Boolean wasWithdrawn)
    {
        this.wasWithdrawn = wasWithdrawn;
    }

    public Roster getRoster()
    {
        return roster;
    }

    // ???
    public void setRoster(Roster roster)
    {
        this.roster = roster;
    }

    public Group getGroup()
    {
        return group;
    }

    // ???
    public void setGroup(Group group)
    {
        this.group = group;
    }

    ...
}

In general, should the association setters synchronize with the redundant fields, here rosterId, roundId, and ordinalNbr?:

    // ???
    public void setGroup(Group group)
    {
        this.group = group;
        this.roundId = group.getRoundId();
        this.ordinalNbr = group.getOrdinalNbr();
    }

Thanks

  • 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-05-18T06:41:39+00:00Added an answer on May 18, 2026 at 6:41 am

    Yes, they should be kept in synch. Although because they are part of the Id you should never be changing these, so it is really only an issue for new objects.

    If you do not keep them in synch, then for a new object they will be null/0, which is probably not good. There is no magic in JPA that will keep these in synch for you.

    If you read the object from the database, then they will be in synch of coarse, but you are responsible for maintaining your object’s state once in memory, including both duplicate fields, and bi-directional mappings.

    If you are using JPA 2.0, why bother having the duplicate Ids at all. You can remove the routersId and the roundId and just add the @Id to the @ManyToOnes.

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

Sidebar

Related Questions

No related questions found

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.