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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:39:20+00:00 2026-06-09T09:39:20+00:00

In hibernate is is possible to map the same column with 2 properties of

  • 0

In hibernate is is possible to map the same column with 2 properties of the same class, and have the possibility to reference both in queries?
Is sounds pointless but it would be worth for what I have to do.
In the underying example I could mark the second getter @Transient to keep the second getter, but I would lose the alias in queries, so I would like to keep both “myPropertyAliasOne” and “myPropertyAliasTwo”.

@Entity
public MyEntity {

   private String myProperty;

   @Column(name="ACTUAL_VALUE")
   public String getMyPropertyAliasOne(){
        return myProperty;
   }

   @Transient
   public String getMyPropertyAliasTwo(){
        return myProperty;
   }
}     
  • 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-09T09:39:22+00:00Added an answer on June 9, 2026 at 9:39 am

    If you want to have one column be mapped to two properties, why don’t you just map one of them and set the other with the value of the first.

    @Entity
    public MyEntity {
    
       @Column(name="ACTUAL_VALUE")
       private String myProperty1;
       private String myProperty2;
    
       public void setMyPropert1(String str){
           myProperty1 = str;
           myProperty2 = str;
       }
       public void setMyPropert2(String str){
           myProperty1 = str;
           myProperty2 = str;
       }
       public void setMyPropert2(){
           myProperty2 = myProperty1;
       }
       @Transient
       public String getMyPropertyAliasOne(){
            return myProperty1;
       }
    
       public String getMyPropertyAliasTwo(){
            return myProperty2;
       }
    } 
    

    In this case, you manually have these properties always the same. (but I don’t get it, why this redundancy is useful?)

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

Sidebar

Related Questions

I am using Hibernate to map with MySQL I have an entity class in
Possible Duplicate: Hibernate: different object with the same identifier value was already associated with
Possible Duplicate: Hibernate: different object with the same identifier value was already associated with
Is it possible to get a StaleObjectStateException with Hibernate when you do the same
I have an application I'd like to test-proof against possible problems related to Hibernate
Is it possible to map a database column to a constant value without the
I'm using Hibernate 3.6 but would prefer to stick to JPA annotations if possible.
Is it possible to map one column twice using NHibernate? <property name=CustomerID index=IX_Customer not-null=true
In hibernate, is it possible to define a mapping for a class to a
I have a very special NHibernate mapping case. The class has a reference to

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.