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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:25:59+00:00 2026-05-25T06:25:59+00:00

I have an abstract entity using DiscriminatorColumn and is subclassed by various entites. Now,

  • 0

I have an abstract entity using DiscriminatorColumn and is subclassed by various entites. Now, when I’m querying named query in the abstract class, it throws an error saying ‘org.hibernate.InstantiationException Cannot instantiate abstract class or interface’. On analysis I found that the discriminator column is not appended in the generated native SQL itself. Following is a simplified version of the Entity Mapping:

  package com.qz.test;

import javax.persistence.*;

/**
 * User: r4rao
 * Date: 7/18/11
 * Time: 5:36 PM
 */
@Entity
@Table(schema = "ems", name = "nlt_content_profile")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "content_profile_type", discriminatorType = DiscriminatorType.STRING)
@NamedQueries({
        @NamedQuery(name = "A.getProfilesForDelivery", query = "select pcp from A pcp where pcp.serviceId = :service_id ")
//      @NamedQuery(name = "A.getProfilesByIdsForDelivery", query = "select pcp,s from A pcp,Subscription s LEFT JOIN FETCH s.client c LEFT JOIN FETCH c.operator where pcp.id in (:cp_ids) and pcp.service.id = :service_id and s.contentProfile.id = pcp.id and s.status in (:statuses) and  (:use_timestamp = false or (:use_timestamp = true and s.beginningTime < :timestamp)))"),
//      @NamedQuery(name = "A.removeUnusedContentProfiles", query = "DELETE FROM A pcp WHERE NOT EXISTS(SELECT 1 FROM Subscription sub WHERE sub.contentProfile.id = pcp.id)"),
//      @NamedQuery(name = "A.getProfileIdsForDelivery", query = "select pcp.id from A pcp where pcp.service.id = :service_id and exists(select 1 from Subscription s where s.contentProfile.id = pcp.id and s.status in (:statuses))")
})
public abstract class A{
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "ContentProfileSeq")
    @SequenceGenerator(name = "ContentProfileSeq", sequenceName = "ems.nlt_content_profile_seq")
    private Long id;

    public Long getId() {
        return id;
    }

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


    @Column(name = "service_id")
    private Long serviceId;

    public Long getServiceId() {
        return serviceId;
    }

    public void setServiceId(Long serviceId) {
        this.serviceId = serviceId;
    }
}

package com.qz.test;

import javax.persistence.*;

/**
 * User: r4rao
 * Date: 7/18/11
 * Time: 5:36 PM
 */
@Entity
public class B extends A {
    @Column(name = "subscription_parameter")
    private String param;

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append("B");
        sb.append("{param='").append(param).append('\'');
        sb.append('}');
        return sb.toString();
    }
}
  • 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-25T06:25:59+00:00Added an answer on May 25, 2026 at 6:25 am

    I figured out it was due to a configuration mistake. Only abstract class was configured in persistence.xml while configuration for any concrete subsclass was missing. On adding configuration for concrete classes, this error was resolved.

    Surprisingly, instead of throwing an appropriate error, it was not appending the filter clause using discriminator column in the generated query.

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

Sidebar

Related Questions

I have an abstract entity: public abstract class Entity extends JPanel implements FocusListener And
I have the following classes in my Model: public abstract class Entity : IEntity
I have an abstract Class Monitor.java which is subclassed by a Class EmailMonitor.java .
I have an abstract entity base class defined like this: public abstract class SessionItem
I have an abstract parent entity with 6 inherited child entities, using TPH in
I have an abstract entity called Block which contains two attributes: column and order
I have a two generic abstract types: Entity and Association . Let's say Entity
I have an AbstractEntity class as superclass for all my entites that defines an
Let say I have abstract class called: Tenant and Customer. The tenant in this
Suppose we have abstract class A (all examples in C#) public abstract class A

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.