1

I am using Liferay 7.3.5 and trying to create an elasticSearch method and have created the required classes KeywordQueryContributor, ModelDocumentContributor, ModelIndexerWriterContributor, SearchRegistrar and ModelSummaryContributor.

Now, from the control panel --> configuration --> Search, I am trying to execute the model, but this error appears .

     ERROR [liferay/background_task-7][BasePersistenceImpl:561] Caught unexpected exception
org.hibernate.QueryException: could not resolve property: companyId of: com.model.TKPRIME
    at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:81)
    at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:75)
    at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassPropertyTableNumber(AbstractEntityPersister.java:1482)
    at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:62)
    at org.hibernate.persister.entity.AbstractEntityPersister.toColumns(AbstractEntityPersister.java:1457)
    at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:483)
    at org.hibernate.loader.criteria.CriteriaQueryTranslator.findColumns(CriteriaQueryTranslator.java:498)
    at org.hibernate.criterion.SimpleExpression.toSqlString(SimpleExpression.java:68)
    at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:380)
    at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:102)
    at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:82)
    at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:92)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1697)
    at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
    at com.liferay.portal.dao.orm.hibernate.DynamicQueryImpl.list(DynamicQueryImpl.java:140)
    at com.liferay.portal.dao.orm.hibernate.DynamicQueryImpl.list(DynamicQueryImpl.java:126)
    at com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl.findWithDynamicQuery(BasePersistenceImpl.java:449)
    at com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl.countWithDynamicQuery(BasePersistenceImpl.java:151)
    at com.portal.ibkdoc.service.base.TKPRIMELocalServiceBaseImpl.dynamicQueryCount(TKPRIMELocalServiceBaseImpl.java:217)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:50)
    at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:69)
    at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
    at com.liferay.change.tracking.internal.aop.CTTransactionAdvice.invoke(CTTransactionAdvice.java:80)
    at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
    at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49)
    at com.sun.proxy.$Proxy1216.dynamicQueryCount(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery.executeDynamicQuery(DefaultActionableDynamicQuery.java:349)
    at com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery.performCount(DefaultActionableDynamicQuery.java:117)
    at com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery.performActions(IndexableActionableDynamicQuery.java:61)
    at com.liferay.portal.search.internal.batch.DynamicQueryBatchIndexingActionableAdapter.performActions(DynamicQueryBatchIndexingActionableAdapter.java:50)
    at com.liferay.portal.search.internal.indexer.IndexerWriterImpl.reindex(IndexerWriterImpl.java:199)
    at com.liferay.portal.search.internal.indexer.DefaultIndexer.reindex(DefaultIndexer.java:267)
    at com.liferay.portal.search.internal.background.task.ReindexSingleIndexerBackgroundTaskExecutor.reindex(ReindexSingleIndexerBackgroundTaskExecutor.java:143)
    at com.liferay.portal.search.internal.background.task.ReindexBackgroundTaskExecutor.execute(ReindexBackgroundTaskExecutor.java:54)
    at com.liferay.portal.background.task.internal.SerialBackgroundTaskExecutor.execute(SerialBackgroundTaskExecutor.java:62)
    at com.liferay.portal.kernel.backgroundtask.DelegatingBackgroundTaskExecutor.execute(DelegatingBackgroundTaskExecutor.java:41)
    at com.liferay.portal.background.task.internal.ThreadLocalAwareBackgroundTaskExecutor.execute(ThreadLocalAwareBackgroundTaskExecutor.java:72)
    at com.liferay.portal.background.task.internal.messaging.BackgroundTaskMessageListener.doReceive(BackgroundTaskMessageListener.java:136)
    at com.liferay.portal.kernel.messaging.BaseMessageListener.doReceive(BaseMessageListener.java:48)
    at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:34)
    at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:74)
    at com.liferay.portal.messaging.internal.ParallelDestination$1.run(ParallelDestination.java:56)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
2021-04-27 08:27:11.073 WARN  [liferay/background_task-7][IndexerWriterImpl:210] Error reindexing all com.model.TKPRIME for company: 20097
com.liferay.portal.kernel.exception.SystemException: org.hibernate.QueryException: could not resolve property: companyId of: com.model.TKPRIMEImpl
    at com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl.processException(BasePersistenceImpl.java:567)
    at com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl.findWithDynamicQuery(BasePersistenceImpl.java:452)
    at com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl.countWithDynamicQuery(BasePersistenceImpl.java:151)
    at com.portal.ibkdoc.service.base.TKPRIMELocalServiceBaseImpl.dynamicQueryCount(TKPRIMELocalServiceBaseImpl.java:217)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:50)
    at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:69)
    at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
    at com.liferay.change.tracking.internal.aop.CTTransactionAdvice.invoke(CTTransactionAdvice.java:80)
    at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
    at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49)
    at com.sun.proxy.$Proxy1216.dynamicQueryCount(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery.executeDynamicQuery(DefaultActionableDynamicQuery.java:349)
    at com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery.performCount(DefaultActionableDynamicQuery.java:117)
    at com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery.performActions(IndexableActionableDynamicQuery.java:61)
    at com.liferay.portal.search.internal.batch.DynamicQueryBatchIndexingActionableAdapter.performActions(DynamicQueryBatchIndexingActionableAdapter.java:50)
    at com.liferay.portal.search.internal.indexer.IndexerWriterImpl.reindex(IndexerWriterImpl.java:199)
    at com.liferay.portal.search.internal.indexer.DefaultIndexer.reindex(DefaultIndexer.java:267)
    at com.liferay.portal.search.internal.background.task.ReindexSingleIndexerBackgroundTaskExecutor.reindex(ReindexSingleIndexerBackgroundTaskExecutor.java:143)
    at com.liferay.portal.search.internal.background.task.ReindexBackgroundTaskExecutor.execute(ReindexBackgroundTaskExecutor.java:54)
    at com.liferay.portal.background.task.internal.SerialBackgroundTaskExecutor.execute(SerialBackgroundTaskExecutor.java:62)
    at com.liferay.portal.kernel.backgroundtask.DelegatingBackgroundTaskExecutor.execute(DelegatingBackgroundTaskExecutor.java:41)
    at com.liferay.portal.background.task.internal.ThreadLocalAwareBackgroundTaskExecutor.execute(ThreadLocalAwareBackgroundTaskExecutor.java:72)
    at com.liferay.portal.background.task.internal.messaging.BackgroundTaskMessageListener.doReceive(BackgroundTaskMessageListener.java:136)
    at com.liferay.portal.kernel.messaging.BaseMessageListener.doReceive(BaseMessageListener.java:48)
    at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:34)
    at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:74)
    at com.liferay.portal.messaging.internal.ParallelDestination$1.run(ParallelDestination.java:56)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.hibernate.QueryException: could not resolve property: companyId of: com.model.TKPRIMEImpl
    at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:81)
    at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:75)
    at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassPropertyTableNumber(AbstractEntityPersister.java:1482)
    at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:62)
    at org.hibernate.persister.entity.AbstractEntityPersister.toColumns(AbstractEntityPersister.java:1457)
    at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:483)
    at org.hibernate.loader.criteria.CriteriaQueryTranslator.findColumns(CriteriaQueryTranslator.java:498)
    at org.hibernate.criterion.SimpleExpression.toSqlString(SimpleExpression.java:68)
    at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:380)
    at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:102)
    at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:82)
    at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:92)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1697)
    at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
    at com.liferay.portal.dao.orm.hibernate.DynamicQueryImpl.list(DynamicQueryImpl.java:140)
    at com.liferay.portal.dao.orm.hibernate.DynamicQueryImpl.list(DynamicQueryImpl.java:126)
    at com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl.findWithDynamicQuery(BasePersistenceImpl.java:449)
    ... 36 more

here is code of ModelIndexerWriterContributor where the companyId is called.Is something still missing or what?

  @Component(
            immediate = true,
            property = "indexer.class.name=com.model.TKPRIME",
            service = ModelIndexerWriterContributor.class
    )
    
    
    public class TKPRIMEModelIndexerWriterContributor
    implements ModelIndexerWriterContributor<TKPRIME> {
        @Reference
        protected DynamicQueryBatchIndexingActionableFactory
        dynamicQueryBatchIndexingActionableFactory;
    
        @Reference
        protected TKPRIMELocalService tkprimeLocalService;
    
    @Override
    public void customize(
        BatchIndexingActionable batchIndexingActionable,
       ModelIndexerWriterDocumentHelper modelIndexerWriterDocumentHelper) {
    
        batchIndexingActionable.setPerformActionMethod((TKPRIME tkprime) -> {
            Document document = modelIndexerWriterDocumentHelper.getDocument(tkprime);
    
            batchIndexingActionable.addDocuments(document);
        });
    }
    
    
    @Override
    public BatchIndexingActionable getBatchIndexingActionable() {
        return dynamicQueryBatchIndexingActionableFactory.getBatchIndexingActionable(
                tkprimeLocalService.getIndexableActionableDynamicQuery());
    }
    
    @Override
    public long getCompanyId(TKPRIME tkprime) {
        return tkprime.getTK_CompanyId();
    }
    
    }

thanks for the help

MaFa
  • 15
  • 5

1 Answers1

0

The last line of the code you provide looks like getCompanyId() is there, so I see two ways to hunt this down:

  • Database (make sure the table for TKPRIME has a field companyId. Include capitalization in your check)
  • Java (if the interface (TKPRIME) has this method, but the implementation (TKPRIMEImpl) doesn't: execute the buildService target again. ServiceBuilder requires rebuilding every now and then - and will show you any mismatches.

Note: If you introduced companyId after your first deployment of the new entity, you might need to create an Upgrade routine to alter your database. Only development systems may automate that (and I'm not even sure if they do by default)

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
  • Thank you for your answer The model in the database definitely has the companyId field. As for Java: the modul and implementation have this method, and after building the server again, no errors appeared – MaFa Apr 28 '21 at 09:04
  • I noticed the sensitivity of the Cases and made adjustments, but that didn't work either – MaFa Apr 28 '21 at 10:00
  • "no error appeared": No compiler error? Or the problem went away? Also: All components deployed after building? (hunting for the low hanging fruit here) – Olaf Kock Apr 28 '21 at 10:09
  • No compiler error and all components deployed after building succesfully but the problem still exists – MaFa Apr 28 '21 at 10:35
  • Do you have other suggestions? – MaFa Apr 29 '21 at 11:13
  • sorry, currently no other idea – Olaf Kock Apr 29 '21 at 13:19
  • I think I didn't understand you well because I'm a beginner. But you have the right, the problem was in the database in which the column name in the database table must match the primary name used by Liferay, and therefore the column name must be the companyId in the following form where it is written in lowercase letters with the exception of the letter i, then a db-name=XXX can be added to label the column as you like – MaFa May 18 '21 at 06:15