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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:24:41+00:00 2026-05-31T02:24:41+00:00

I have an abstract entity that 4 other entities inherit from. This relationship works

  • 0

I have an abstract entity that 4 other entities inherit from. This relationship works well, however I want to query the abstract entity so that I get all entities regardless of their types. I have no idea where to place such a method since the parent entity dao is also abstract.

EntityParent (abstract) -> EntityType1, EntityType2, EntityType3, EntityType4

DAOs look like this:

EntityParentDAO (abstract) -> EntityType1DAO, EntityType2DAO, EntityType3DAO, EntityType4DAO

TX also look like this:
EntityParentTx (abstract) -> EntityType1Tx, EntityType2Tx, EntityType3Tx, EntityType4Tx

My project structure goes as follows:
Entities -> DAO for each entity -> TX for each DAO -> Service combining several TXs

There is Service which uses all of the *TX*s that’s within the scope of my project. Is this where a criteria/HQL query should be placed? That doesn’t sound quite right.

For example let’s say I have a Car parent entity and that I have children entities Coupe, Sedan, Minivan and so on and I want a list of cars given a property that is common to all and therefore in the entity (and it its table) Car. Where would I place this query/method given the structure I’m following?

  • 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-31T02:24:42+00:00Added an answer on May 31, 2026 at 2:24 am

    I’m not sure I follow the transaction inheritance, but why not make the parent dao concrete and add it there? As long as the parent is an Entity, and it has the field, you can query on it. The return type will be a list of the base type, but it will be instances of the actual type.

    Ex:

    @Entity
    @Table(name = "table")
    @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
    @DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.INTEGER)
    public abstract class ParentImpl implements Parent{}
    
    @Entity
    @DiscriminatorValue("1")
    public class Entity1Impl extends ParentImpl {}
    
    public interface AbstractDao<T extends Parent> {}
    
    public interface ConcreteParentDao<Parent> {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a base class that looks like this: public abstract class MyBaseClass {
I have a base class that I inherit from that has two zero to
I have an application that contains a business entity called a 'Task'. This entity
I have this Person class that is part of various other transactions like a
I have an abstract entity called Block which contains two attributes: column and order
I have an abstract entity: public abstract class Entity extends JPanel implements FocusListener And
I have a two generic abstract types: Entity and Association . Let's say Entity
I have the following classes in my Model: public abstract class Entity : IEntity
Let say I have abstract class called: Tenant and Customer. The tenant in this
I have about 10 different entities in my J2EE application that right now share

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.