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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:13:52+00:00 2026-05-20T06:13:52+00:00

I have the following data model: @Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public abstract class AbstractRecord

  • 0

I have the following data model:

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class AbstractRecord
    implements Serializable
{
    ...
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    @Column(name = "id", nullable = false)
    @DocumentId
    private Integer id;
    ...

}

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@NamedQueries(...)
})
public abstract class AbstractEntryDetail
    extends AbstractRecord
    implements Serializable
{
...
}

@Indexed(index = "entryDetailIndex")
@Entity
@Table(name = "nacha_entry_detail")
@NamedQueries(...)
})
public class EntryDetail
    extends AbstractEntryDetail
    implements Serializable
{
    ...
    @Field(index = Index.TOKENIZED, store = Store.NO)
    @Column(name = "receiver_name", nullable = false)
    private String receiverName;
    ...

}

@Indexed(index = "entryDetailCtxIndex")
@Entity
@Table(name = "nacha_entry_detail_ctx")
@NamedQueries(...)
public class EntryDetailCtx
    extends AbstractEntryDetail
    implements Serializable
{
    ...
    @Field(index = Index.TOKENIZED, store = Store.NO)
    @Column(name = "receiver_name", nullable = false)
    private String receiverName;
    ...
}

As you can see, EntryDetail and EntryDetailCtx share the same property “receiverName”, I am having a problem when searching for a value say “IndividualName1” through the following code:

@Stateless
@TransactionAttribute(TransactionAttributeType.MANDATORY)
@RolesAllowed({PermissionUtil.SEARCH_LIST,
    PermissionUtil.LUCENE_INDEX
})
public class SearchFacade
{
    ...
    @RolesAllowed(PermissionUtil.SEARCH_LIST)
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public List<AbstractRecord> doSearch(String stringToFind)
    {
        List<AbstractRecord> result = null;

        // Test Search for specific values of an Abstract Record
        // Aim to return the number of retreived results
        EntityManager em = emf.createEntityManager();
        FullTextEntityManager fullTextEntityManager =
            org.hibernate.search.jpa.Search.getFullTextEntityManager(em);
        String[] fields =
            // Fields to be reviewed
            new String[]
            {   ....,"receiverName",.... 
            };

        //Create a multi-field Lucene query
        StandardAnalyzer stdAnalyzer = new StandardAnalyzer(Version.LUCENE_30);
        MultiFieldQueryParser parser =
            new MultiFieldQueryParser(Version.LUCENE_30, fields, stdAnalyzer);
        org.apache.lucene.search.Query query = null;

        try
        {
            query = parser.parse(stringToFind);
        }
        catch (ParseException ex)
        {
            Logger.getLogger(SearchFacade.class.getName()).log(Level.SEVERE, null, ex);
        }

        long time1 = System.currentTimeMillis();

        // Wrap Lucene query in a javax.persistence.Query
        javax.persistence.Query persistenceQuery =
            fullTextEntityManager.createFullTextQuery(query);
        // Execute search
        //HAVING PROBLEMS HERE
        result = (List<AbstractRecord>) persistenceQuery.getResultList();

        long time2 = System.currentTimeMillis();
        Logger.getLogger(SearchFacade.class.getName())
              .log(
            Level.FINER, "Hibernate Search Execution time: {0}",
            Long.toString(time2 - time1));

        //em.getTransaction().commit();
        em.close();

        return result;
    }

So after indexing the entities and trying to perform a search on a “receiverName” that is shared on my data base, say “Jhon” I get the following exception..

Caused by: org.hibernate.WrongClassException: Object with id: 1 was not of the specified subclass: com.xxx.ejb.core.entity.nacha.EntryDetailCtx (loaded object was of wrong class class com.xxx.ejb.core.entity.nacha.EntryDetail)
    at org.hibernate.loader.Loader.instanceAlreadyLoaded(Loader.java:1391)
    at org.hibernate.loader.Loader.getRow(Loader.java:1344)
    at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:611)
    at org.hibernate.loader.Loader.doQuery(Loader.java:829)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
    at org.hibernate.loader.Loader.doList(Loader.java:2533)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
    at org.hibernate.loader.Loader.list(Loader.java:2271)
    at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
    at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
    at org.hibernate.search.engine.ObjectLoaderHelper.initializeObjects(ObjectLoaderHelper.java:116)
    at org.hibernate.search.engine.MultiClassesQueryLoader.executeLoad(MultiClassesQueryLoader.java:124)
    at org.hibernate.search.engine.AbstractLoader.load(AbstractLoader.java:70)
    at org.hibernate.search.query.FullTextQueryImpl.list(FullTextQueryImpl.java:317)
    at org.hibernate.search.jpa.impl.FullTextQueryImpl.getResultList(FullTextQueryImpl.java:137)
    at com.paysett.ejb.core.facade.SearchFacade.doSearch(SearchFacade.java:130)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1056)
    at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1128)
    at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5292)
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:615)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:797)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:567)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:157)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:139)
    at sun.reflect.GeneratedMethodAccessor525.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:858)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:797)
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:367)
    at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5264)
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5252)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:190)
    ... 52 more

I have read throughly many hibernate search forums and even Hibernate Search in Action book without any positive results, ca anyone light me up with ideas or possible solutions to this problem?
Thanks

EDIT: Found out that the problem was that EntryDetail and EntryDetailCtx both can have same ID’s (Because both are on different tables..) however since @documentID which is inherited from AbstractRecord can be duplicated in both tables at search execution time generates the problem… Now I have an additional problem and it is the following:

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class AbstractRecord
    implements Serializable
{
    //~ Instance variables ---------------------------------------------------------------
/** SERIALID */ public static final String SERIALID = "hyzmfgSwl5hsDbxZIitNILMT2/eiPYJErJcqIMun3/PVy3SbbiQie4k9lLnL450BhwL8EnUMyc+wrhgZtUBTdG9/YUuJ+ni/FRAdRGzTy7UrQI7opbrYRYehDUwj3hg9";
    /** id for this record. */
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    @Column(name = "id", nullable = false)
    private Integer id;

    /** line number for this record. */
    @Field(index=Index.UN_TOKENIZED, store=Store.NO)
    @Column(name = "record_number", nullable = false)
    private Integer recordNumber;

    /** record types for this record. */
    @Field(index=Index.UN_TOKENIZED, store=Store.NO)
    @Column(name = "record_type", nullable = false)
    private Integer recordType;

    /** Current status for this record. */
    @Field(index=Index.UN_TOKENIZED, store=Store.NO)
    @Column(name = "record_status", nullable = false)
    @Enumerated(EnumType.ORDINAL)
    private RecordStatus recordStatus;

    /** unique table key for the file. */
    @Field(index=Index.UN_TOKENIZED, store=Store.NO)
    @Column(name = "unique_table_key", nullable = false)
    private String uniqueTableKey;

    ...
}

I need uniqueTableKey and recordNumber to be my new @documentID’s for the search, however Hibernate search only allows 1 documentId, help?

  • 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-20T06:13:53+00:00Added an answer on May 20, 2026 at 6:13 am

    Possible solutions to this problem are the following:
    EmbeededID
    and
    Idclass

    And then annotating as @DocumentId any of the above chosen solutions

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

Sidebar

Related Questions

I have the following model entity: public class ScheduledTask { public virtual int ScheduledTaskId
I have following data structure (simplified): A giant list of the class TestClass public
I have the following core data model with two entities: entity item which holds
I have a core data model with the following info: Entity: CourseSubjects Attributes: -account_id
I have the following data model: I am writing a WCF service that needs
I've got an architecture like the following: Data (Class Library that handles our Entity
Given the following Core Data Model: -> : to-one releationship ->>: to-many relationship Entity
I have an ADO.NET Entity Data Model and want to plumb up a DataGridView
I have a Core Data model entity NoteObject that has a transformable type arrayOfTags
I have two tables in my entity data model (converted from an old database)

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.