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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:12:43+00:00 2026-06-13T05:12:43+00:00

I want to have versions from the same data entry. In other words, I

  • 0

I want to have versions from the same data entry. In other words, I want to duplicate the entry with another version number.

id - Version will be the primary key.

How should the entity look like? How can I duplicate it with another version?

id Version ColumnA

1   0      Some data
1   1      Some Other data
2   0      Data 2. Entry
2   1      Data
  • 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-13T05:12:45+00:00Added an answer on June 13, 2026 at 5:12 am

    You can make an Embedded class, which contains your two keys, and then have a reference to that class as EmbeddedId in your Entity.

    You would need the @EmbeddedId and @Embeddable annotations.

    @Entity
    public class YourEntity {
        @EmbeddedId
        private MyKey myKey;
    
        @Column(name = "ColumnA")
        private String columnA;
    
        /** Your getters and setters **/
    }
    
    @Embeddable
    public class MyKey implements Serializable {
    
        @Column(name = "Id", nullable = false)
        private int id;
    
        @Column(name = "Version", nullable = false)
        private int version;
    
        /** getters and setters **/
    }
    

    Another way to achieve this task is to use @IdClass annotation, and place both your id in that IdClass. Now you can use normal @Id annotation on both the attributes

    @Entity
    @IdClass(MyKey.class)
    public class YourEntity {
       @Id
       private int id;
       @Id
       private int version;
    
    }
    

    public class MyKey implements Serializable {
       private int id;
       private int version;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small script and want to detect the script version from admin
We have two version of the same assembly in GAC? I want my client
Hi I have a sqlite3 database full of data from my previous version of
I have an App that I want to have two version in the App
I currently have version 5.2.37 and I want to update to 5.2.38. How do
I have an app version 1.0 which is on Appstore, now I want to
We have certain configuration files which we want to be in version control as
I currently have MVS2008 and I want to try the 2010 version hoping that
I want install Android version 1.6 SDK. I already have Android development setup with
I have download entire Eclipse Helios/Indigo version Source Code. Now I want to work

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.