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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:35:03+00:00 2026-05-23T23:35:03+00:00

Given the class below does anyone know why EclipseLink implementation of JPA fails to

  • 0

Given the class below does anyone know why EclipseLink implementation of JPA fails to map them to database entities? The following error is returned:

Entity class [class com.my.entity.Y] 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.

@Entity
@Access(AccessType.PROPERTY)
public interface Y {

    void setId(Long id);

    @Id
    Long getId();
}

@Entity
public class Z implements Y {

    long id;

    @Override
    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public Long getId() {
        return id;
    }
}

Many 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-23T23:35:04+00:00Added an answer on May 23, 2026 at 11:35 pm

    Thanks to the person who linked to this question – it helped me come up with a solution to the issue as follows:

        @Entity
        public interface Y {
    
            void setId(Long id);
    
            @Id
            Long getId();
        }
    
       // introduce intermediate abstract class which implements Y
    
        @Entity
        public abstract class X implements Y {
    
        }
    
        // make Z extends X
    
        @Entity
        public class Z  extends X {
    
            // use targetEntity = X.class where required
            // leaving this class still free to use interface Y
    
            long id;
    
            @Override
            public void setId(Long id) {
                this.id = id;
            }
    
            @Override
            public Long getId() {
                return id;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know about the container jar file for the class given below. Please
I have a data structure which is as given below: class File { public
I have a class with a set of properties As given below. class ContactInfo
Following class structure is given: class Job { String description; Collection<JobHistory> history; } class
Does anyone here know of any quick, clean way to convert csv files to
Does anyone know of a truly declarative language? The behavior I'm looking for is
Does anyone know of any resources or books I can read to help me
Short Version: Does anyone know how to do a simple date insert using Doctrine2?
In the example enumeration code given in this question , reproduced below, why does
When I try to compile the example code given below, I get the following

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.