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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:27:44+00:00 2026-06-08T09:27:44+00:00

@Embeddable @MappedSuperclass public class Address { private String street; private String city; public String

  • 0
@Embeddable
@MappedSuperclass
public class Address {
  private String street;
  private String city;

public String getStreet(){ return street;}
public String getCity(){ return city;}
public String setStreet(Sting street){ this.street= street;}
public String setCity(String city){ this.city=city;}

}

import org.hibernate.annotations.Entity;
@Entity
public class AddressHistory extends Address {
 Long id;
 @Id @XmlTransient
 @GeneratedValue(strategy = GenerationType.AUTO)
  public Long getId() {
    return m_id;
  }

 public void setId(Long m_id) {
    this.m_id = m_id;
 }
}

Here is my scenario, I want to store address of a person. And I also have to store all the address that a person has live before. So what I am doing is I am embedding current address in person table and would like to store all his/her pervious address in history table. To achieve this. I made Address class embeddable and embedded it into person table and HistoryAddress table. But as of OOPS concept. HistoryAddress is a Address, so it is not good to do composition of Address class into AddressHistory. Then I decided to extends AddressHistory from Address class. BUt when I do this hibernate gives me this error

Use of @OneToMany or @ManyToMany targeting an unmapped class AddressHistory.

But clearly I have mapped AddressHistory
Can we do this ? Can we extend Entity from Embedded class ?

  • 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-08T09:27:45+00:00Added an answer on June 8, 2026 at 9:27 am

    No, entity cannot extend embeddable. In JPA 2.0 specification this is told as follows:

    An entity can have a non-entity superclass, which may be either a
    concrete or abstract class.[22]
    …
    [22] The superclass must not be an
    embeddable class or id class.

    Also target of relationship must be Entity. Embeddable is not entity, it does not have identity of its own. If you want collection of embeddables, use @ElementCollection.

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

Sidebar

Related Questions

I have class @Embeddable public class MyClass implements Serializable { private String field1; private
I am using an embedded id: @Embeddable public class EntityId { private long id;
I have class Money which is an @Embeddable @Embeddable public class Money implements Serializable,
I have problems creating a custom query. This is what entities: @Entity public class
The problem is the following. I have an Embeddable class (say, Address ) wuth
I am trying to use an inner class as embeddable to represent some complicated
Do you know something just like this , but embeddable in a C program?
I'm trying to map an @Embeddable object in a subclass whose parent class already
I have a DateInterval class that is annotated with @Embeddable and it has two
I'm breaking my head over this. I'm trying to insert embeddable video code, such

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.