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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:17:20+00:00 2026-05-24T08:17:20+00:00

I am trying to adapt my data model to use a BaseEntity base-class. The

  • 0

I am trying to adapt my data model to use a BaseEntity base-class. The following code represents the general idea:

    @MappedSuperclass
    public abstract class BaseEntity implements HasAuditInfo {
        @Id
        @GeneratedValue
        private Long id;
        @Column(unique = true, nullable = false)
        private String uuid;
        private Long createdById;
        @Temporal(value = TemporalType.TIMESTAMP)
        @Column(nullable = false)
        private Date createdOn;
        private Long changedById;
        @Temporal(value = TemporalType.TIMESTAMP)
        @Column(nullable = false)
        private Date changedOn;
        @Column(nullable = false)
        private Long changedOnValue;
        private Boolean active;
        private Long deactivatedById;
        @Temporal(value = TemporalType.TIMESTAMP)
        private Date deactivatedOn;
        @NotNull
        @DecimalMin("0")
        private Integer version = 0;
        private Long domainId;

        [... Getters/Setters etc ...]
}

The following is an example of a derived entity:

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Address extends BaseEntity implements Serializable, Comparable<Address> {
    private static final long serialVersionUID = 6301090657382674578L;
    // Address Fields
    @NotBlank(message = "Address Line 1 is a mandatory field.")
    private String addressLine1;
    private String addressLine2;
    private String country;
    @NotBlank(message = "Region is a mandatory field.")
    private String region;
    @NotBlank(message = "City is a mandatory field.")
    private String city;
    @NotBlank(message = "Zipcode is a mandatory field.")
    private String zipcode;

    [... Getters/Setters etc ...]
}

If I’m understanding the JPA documentation correctly, this should be perfectly valid, yet I get the following error from EclipseLink when deploying my code:

Entity class [class
com.x.y.z.Address] has no primary key specified.
It should define either an @Id, @EmbeddedId or an @IdClass. If you
have defined PK using any of these annotations then make sure that you
do not have mixed access-type (both fields and properties annotated)
in your entity class hierarchy.

I’ve tried a few things to work around this:

  • Upgrading to EclipseLink 2.3 (I’m currently using 2.2)
  • Making BaseEntity non-abstract
  • Moving the @Id annotation and field directly into Address
  • Annotating the getId() method instead of field both in BaseEntity and in Address.

None of these approaches have had any effect, short of migrating my code to Hibernate (or some other, better, JPA implementation), is there anything I can do?

  • 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-24T08:17:21+00:00Added an answer on May 24, 2026 at 8:17 am

    The solution is to explicitly name each column in BaseEntity, as follows:

    @MappedSuperclass
    public abstract class BaseEntity {
           @Id
           @GeneratedValue
           @Column(name = "id")
           @SearchableId
           protected Long id;
           @Column(name = "uuid", unique = true, nullable = false)
           protected String uuid;
           @Column(name = "createdById")
           protected Long createdById;
           @Temporal(value = TemporalType.TIMESTAMP)
           @Column(name = "createdOn", nullable = false)
           protected Date createdOn;
           @Column(name = "changedById")
           protected Long changedById;
           @Temporal(value = TemporalType.TIMESTAMP)
           @Column(name = "changedOn", nullable = false)
           protected Date changedOn;
           @Column(name = "changedOnValue", nullable = false)
           protected Long changedOnValue;
           @Column(name = "active")
           protected Boolean active;
           @Column(name = "deactivatedById")
           protected Long deactivatedById;
           @Temporal(value = TemporalType.TIMESTAMP)
           @Column(name = "deactivatedOn")
           protected Date deactivatedOn;
           @Version
           @Column(name = "version")
           protected Integer version = 0;
           @Column(name = "domainId")
           protected Long domainId;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to adapt a simple WPF application to use the Model-View-ViewModel pattern.
Hy there, I'm trying to adapt an existing code to boost::variant. The idea is
I am trying to adapt an existing code to a 64 bit machine. The
I am trying to adapt the underlying structure of plotting code (matplotlib) that is
I'm trying to adapt a code to extract information from wunderground. However the script
Im trying to adapt some code that I have found online that uses this
I'm trying to get some code going that lets me display raw trackpad data
I am trying to adapt an existing program (internally written) to use a different
This code was established in a previous post. I'm trying to adapt it to
I'm trying to adapt this answer How do I tokenize a string in C++?

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.