SystemRecordQuery error

Any issue about Cyclos 4 scripting and Webservices

Moderators: alexandre, hugo, rmvanarkel

Post Reply
EdwinMor
Posts: 22
Joined: Tue Sep 15, 2020 10:31 am
Location: El Salvador
Contact:

SystemRecordQuery error

Post by EdwinMor »

I have stumbled into an unexpected error when executing a SystemRecordQuery on a script.

The code of the script is the following:

Code: Select all

import org.cyclos.model.users.records.SystemRecordQuery
import org.cyclos.model.users.recordtypes.RecordTypeVO
import org.cyclos.model.system.fields.CustomFieldValueVO
import org.cyclos.model.users.records.RecordVO

def recordTypeName = scriptParameters.recordTypeName
def recordType = entityManagerHandler.find(SystemRecordQuery, recordTypeName)
def recordQuery = new SystemRecordQuery()
recordQuery.type = new RecordTypeVO(internalName: recordTypeName)
def records = recordService.search(recordQuery)
}
And the error log that I receive after runing the script is the following:
Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.7.9.v20210604-2c549e2208): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Problem compiling [FROM SystemRecordQuery e WHERE e.internalName = :fieldValue].
[5, 22] The abstract schema type 'SystemRecordQuery' is unknown.
[31, 45] The state field path 'e.internalName' cannot be resolved to a valid type.
at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildException(HermesParser.java:157)
at org.eclipse.persistence.internal.jpa.jpql.HermesParser.validate(HermesParser.java:349)
at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:280)
at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:165)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:142)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:118)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:104)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:88)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1749)
... 115 more

Is there anything I am doing wrong on the code of the script?
luis
Posts: 265
Joined: Fri Feb 17, 2006 11:01 am

Re: SystemRecordQuery error

Post by luis »

In this line you're passing in the SystemRecordQuery to find, whereas it should be SystemRecord (import org.cyclos.entities.users.SystemRecord):

Code: Select all

def recordType = entityManagerHandler.find(SystemRecordQuery, recordTypeName)
However, as you're not using the recordType variable anywhere, you can just remove the line.
Luis Fernando Planella Gonzalez
Cyclos development team
EdwinMor
Posts: 22
Joined: Tue Sep 15, 2020 10:31 am
Location: El Salvador
Contact:

Re: SystemRecordQuery error

Post by EdwinMor »

Silly mistake on my side...

Thank you for the help Luis.
Post Reply