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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:47:12+00:00 2026-06-17T09:47:12+00:00

I have an abstract class that provides some common functionality that some of the

  • 0

I have an abstract class that provides some common functionality that some of the EJB entities which to inherit. One of these is a timestamp column.

public abstract class AbstractEntity {

    ...
    private long lastModified;
    ...

    @Column
    public long getLastModified() {
        return lastModified;
    }

    public void setLastModified(long ts) {
       lastModified = ts;
    }
}

and

@Table
@Entity
public class MyEntity extends AbstractEntity {
    ...
    private Long key;
    private String value;
    ...

    @Id
    public Long getKey() {
        return key;
    }

    public void setKey(Long k) {
        key = k;
    }

    @Column
    public String getValue() {
        return value;
    }

    public void setValue(String txt) {
        value = txt;
        setLastModified(System.currentTimeMillis());
    }
}

The issue is that the timestamp column is not being added to the database table. Is there some annotation that needs to be added to AbstractEntity in order for the lastModified fields to be inherited as a column?

I tried adding @Entity to the AbstractEntity but that caused an exception at deployment.

org.hibernate.AnnotationException: No identifier specified for entity:
AbstractEntity
  • 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-17T09:47:13+00:00Added an answer on June 17, 2026 at 9:47 am

    You have several possibilities here.

    You did not define a mapping for your superclass. If it is supposed to be a queryable type, you should annotate it with @Entity and you would also need an @Id attribute (this missing @Id attribute is the reason for the error you are getting after adding the @Entity annotation)

    If you do not need the abstract superclass to be a queryable entity, but would like to have it’s attributes as columns in tables of it’s subclasses, you need to annotate it with @MappedSuperclass

    If you do not annotate your superclass at all, it is considered to be transient by the provider and is not mapped at all.

    EDIT: By the way, you do not have to modify the lastModified value yourself (except you really want to) – you can let the persistence provider do it for you each time you persist the entity with a lifecycle callback:

    @PreUpdate
    void updateModificationTimestamp() {
     lastModified = System.currentTimeMillis();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a Generic abstract class that provides some default constructor functionality so
I have a collection of classes that inherit from an abstract class I created.
I have a base controller class that exposes some logging functionality to it's child
I have an abstract class that implements IDisposable, like so: public abstract class ConnectionAccessor
I have an abstract class that has a virtual method. The method is virtual
I have an abstract base class that holds a Dictionary. I'd like inherited classes
I have a abstract base class that I have many inherited classes coming off
What if I have a class that both extends an abstract class and implements
I have a class that inherits from Page, called APage. public abstract class APage:
First suppose that I have an abstract class, let's call it AbstractClass. Suppose public

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.